Skip to content

Commit

Permalink
[FIX] l10n_it_fatturapa_in: Check if tax exists before comparing it
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMule71 committed Jun 15, 2021
1 parent 6e75ad1 commit 3dbe483
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,22 +483,24 @@ def adjust_accounting_data(self, product, line_vals):
new_tax = product.product_tmpl_id.supplier_taxes_id[0]
elif len(account.tax_ids) == 1:
new_tax = account.tax_ids[0]
if new_tax:
line_tax_id = line_vals.get("tax_ids") and line_vals["tax_ids"][0][2][0]
line_tax = self.env["account.tax"].browse(line_tax_id)
if new_tax.id != line_tax_id:
if line_tax and new_tax._get_tax_amount() != line_tax._get_tax_amount():
self.log_inconsistency(
_(
"XML contains tax %s. Product %s has tax %s. Using "
"the XML one"
)
% (line_tax.name, product.name, new_tax.name)
line_tax_id = (
line_vals.get("invoice_line_tax_ids")
and line_vals["invoice_line_tax_ids"][0][2][0]
)
line_tax = self.env["account.tax"].browse(line_tax_id)
if new_tax and line_tax and new_tax != line_tax:
if new_tax._get_tax_amount() != line_tax._get_tax_amount():
self.log_inconsistency(
_(
"XML contains tax %s. Product %s has tax %s. Using "
"the XML one"
)
else:
# If product has the same amount of the one in XML,
# I use it. Typical case: 22% det 50%
line_vals["tax_ids"] = [(6, 0, [new_tax.id])]
% (line_tax.name, product.name, new_tax.name)
)
else:
# If product has the same amount of the one in XML,
# I use it. Typical case: 22% det 50%
line_vals["invoice_line_tax_ids"] = [(6, 0, [new_tax.id])]

# move_line.tax_ids
# move_line.name
Expand Down

0 comments on commit 3dbe483

Please sign in to comment.