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 d589651
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
21 changes: 21 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,27 @@ 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",
compute="_compute_use_parent_codice_destinatario",
inverse="_inverse_use_parent_codice_destinatario",
store=True,
help="Instead of using the deafult 0000000 code uses the one set in the parent",
)

@api.depends("electronic_invoice_use_this_address")
def _compute_use_parent_codice_destinatario(self):
for record in self:
if record.electronic_invoice_use_this_address:
record.use_parent_codice_destinatario = False

def _inverse_use_parent_codice_destinatario(self):
for record in self:
if (
record.electronic_invoice_use_this_address
and record.use_parent_codice_destinatario
):
record.use_parent_codice_destinatario = False

Check warning on line 36 in l10n_it_fatturapa_out/models/partner.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/models/partner.py#L36

Added line #L36 was not covered by tests

@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 d589651

Please sign in to comment.