Skip to content

Commit

Permalink
[IMP] l10n_it_fatturapa_out: use parent codice_destinatario
Browse files Browse the repository at this point in the history
Uses the parent codice_destinatario if the partner
has set the flag use_parent_codice_destinatario
to do so.
  • Loading branch information
toita86 committed Nov 6, 2024
1 parent 54a3979 commit d7b6c4e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions l10n_it_fatturapa_out/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class ResPartner(models.Model):
default=lambda self: self.env.company.max_invoice_in_xml,
help="Maximum number of invoices to group in a single " "XML file. 0=Unlimited",
)
use_parent_codice_destinatario = fields.Boolean(
string="Use parent Codice Destinatario",
default=False,
help="Instead of using the deafult 0000000 code uses the one set in the parent",
)

@api.constrains("max_invoice_in_xml")
def _validate_max_invoice_in_xml(self):
Expand Down
10 changes: 10 additions & 0 deletions l10n_it_fatturapa_out/views/partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
<field name="ipa_code" position="before">
<field name="max_invoice_in_xml" />
</field>
<xpath
expr="//field[@name='electronic_invoice_subjected']"
position="before"
>
<field name="electronic_invoice_use_this_address" invisible="1" />
<field
name="use_parent_codice_destinatario"
attrs="{'invisible': ['|', ('is_company', '=', True), ('electronic_invoice_use_this_address', '=', True)]}"
/>
</xpath>
</field>
</record>

Expand Down
8 changes: 7 additions & 1 deletion l10n_it_fatturapa_out/wizard/efattura.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ def fpa_to_eur(amount, invoice):
# check value code
code = self.partner_id.ipa_code
else:
code = self.partner_id.codice_destinatario
if (
self.partner_id.use_parent_codice_destinatario
and not self.partner_id.is_company
):
code = self.partner_id.parent_id.codice_destinatario

Check warning on line 213 in l10n_it_fatturapa_out/wizard/efattura.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/wizard/efattura.py#L213

Added line #L213 was not covered by tests
else:
code = self.partner_id.codice_destinatario

# Create file content.
template_values = {
Expand Down

0 comments on commit d7b6c4e

Please sign in to comment.