Skip to content

Commit

Permalink
[FIX] url widget not translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
primes2h committed Nov 21, 2022
1 parent 8aed190 commit 9f3e1ff
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
9 changes: 9 additions & 0 deletions l10n_it_fatturapa/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ def _compute_ftpa_preview_link(self):
att.get_base_url() + "/fatturapa/preview/%s" % att.id
)

@staticmethod
def ftpa_preview(self):
return {
"type": "ir.actions.act_url",
"name": "Show preview",
"url": self.ftpa_preview_link,
"target": "new",
}

def remove_xades_sign(self, xml):
# Recovering parser is needed for files where strings like
# xmlns:ds="http://www.w3.org/2000/09/xmldsig#""
Expand Down
3 changes: 3 additions & 0 deletions l10n_it_fatturapa_in/models/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,6 @@ def extract_attachments(self, AttachmentsData, invoice_id):
"invoice_id": invoice_id,
}
AttachModel.create(_attach_dict)

def ftpa_preview(self):
return self.env["ir.attachment"].ftpa_preview(self)
19 changes: 12 additions & 7 deletions l10n_it_fatturapa_in/views/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@
<field name='id' invisible="1" />
<label for="datas" />
<div>
<field name="datas" filename="name" />
<field
name="ftpa_preview_link"
widget="url"
text="Show preview"
attrs="{'invisible': [('id', '=', False)]}"
/>
<div>
<field name="datas" filename="name" />
</div>
<div>
<button
type="object"
name="ftpa_preview"
string="Show preview"
style="margin-bottom:10px;"
attrs="{'invisible': [('id', '=', False)]}"
/>
</div>
<button
type="object"
name="recompute_xml_fields"
Expand Down
3 changes: 3 additions & 0 deletions l10n_it_fatturapa_out/models/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def _compute_has_pdf_invoice_print(self):
# one attachment having is_pdf_invoice_print = True
attachment_out.has_pdf_invoice_print = True

def ftpa_preview(self):
return self.env["ir.attachment"].ftpa_preview(self)

def reset_to_ready(self):
for attachment_out in self:
if attachment_out.state != "sender_error":
Expand Down
25 changes: 15 additions & 10 deletions l10n_it_fatturapa_out/views/attachment_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,21 @@
<group>
<label for="datas" />
<div>
<field
name="datas"
filename="name"
attrs="{'readonly': [('state', 'not in', ['ready', 'sender_error'])]}"
/>
<field
name="ftpa_preview_link"
widget="url"
text="Show preview"
/>
<div>
<field
name="datas"
filename="name"
attrs="{'readonly': [('state', 'not in', ['ready', 'sender_error'])]}"
/>
</div>
<div>
<button
type="object"
name="ftpa_preview"
string="Show preview"
style="margin-bottom:10px;"
/>
</div>
</div>
<field name="name" />
</group>
Expand Down

0 comments on commit 9f3e1ff

Please sign in to comment.