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 for each child
if the parent has set the flag use_parent_codice_destinatario.
  • Loading branch information
toita86 committed Nov 6, 2024
1 parent 54a3979 commit eb08f30
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 7 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,13 @@ 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",
store=True,
default=False,
help="Instead of using the deafult 0000000 code"
"uses for the childs the one set in the parent",
)

@api.constrains("max_invoice_in_xml")
def _validate_max_invoice_in_xml(self):
Expand Down
3 changes: 3 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,9 @@
<field name="ipa_code" position="before">
<field name="max_invoice_in_xml" />
</field>
<xpath expr="//field[@name='codice_destinatario']" position="before">
<field name="use_parent_codice_destinatario" />
</xpath>
</field>
</record>

Expand Down
9 changes: 8 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,14 @@ def fpa_to_eur(amount, invoice):
# check value code
code = self.partner_id.ipa_code
else:
code = self.partner_id.codice_destinatario
if (
not self.partner_id.is_company
and not self.partner_id.electronic_invoice_use_this_address
and self.partner_id.parent_id.use_parent_codice_destinatario
):
code = self.partner_id.parent_id.codice_destinatario

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

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/wizard/efattura.py#L214

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

# Create file content.
template_values = {
Expand Down

0 comments on commit eb08f30

Please sign in to comment.