Skip to content

Commit

Permalink
[15.0][IMP] l10n_fr_intrastat_product:
Browse files Browse the repository at this point in the history
We don't need fiscal representative if partner is from Europe
  • Loading branch information
yankinmax committed Feb 15, 2023
1 parent 712b59f commit 4903adf
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions l10n_fr_intrastat_product/models/intrastat_product_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,28 @@ def _update_computation_line_vals(self, inv_line, line_vals, notedict):
inv = inv_line.move_id
commercial_partner = inv.commercial_partner_id
eu_countries = self.env.ref("base.europe").country_ids
if (
commercial_partner.country_id not in eu_countries
and not commercial_partner.intrastat_fiscal_representative_id
):
line_notes = [
_("Missing fiscal representative on partner '%s'.")
% commercial_partner.display_name
]
self._format_line_note(inv_line, notedict, line_notes)
else:
fiscal_rep = commercial_partner.intrastat_fiscal_representative_id
if not fiscal_rep.vat:
if commercial_partner.country_id not in eu_countries:
if not commercial_partner.intrastat_fiscal_representative_id:
line_notes = [
_(
"Missing VAT number on partner '{fiscal_rep}' which is the "
"fiscal representative of partner '{partner}'."
).format(
fiscal_rep=fiscal_rep.display_name,
partner=commercial_partner.display_name,
)
_("Missing fiscal representative on partner '%s'.")
% commercial_partner.display_name
]
self._format_line_note(inv_line, notedict, line_notes)
else:
line_vals["vat"] = fiscal_rep.vat
fiscal_rep = commercial_partner.intrastat_fiscal_representative_id

Check warning on line 127 in l10n_fr_intrastat_product/models/intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_fr_intrastat_product/models/intrastat_product_declaration.py#L127

Added line #L127 was not covered by tests
if not fiscal_rep.vat:
line_notes = [

Check warning on line 129 in l10n_fr_intrastat_product/models/intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_fr_intrastat_product/models/intrastat_product_declaration.py#L129

Added line #L129 was not covered by tests
_(
"Missing VAT number on partner '{fiscal_rep}' which is the "
"fiscal representative of partner '{partner}'."
).format(
fiscal_rep=fiscal_rep.display_name,
partner=commercial_partner.display_name,
)
]
self._format_line_note(inv_line, notedict, line_notes)

Check warning on line 138 in l10n_fr_intrastat_product/models/intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_fr_intrastat_product/models/intrastat_product_declaration.py#L138

Added line #L138 was not covered by tests
else:
line_vals["vat"] = fiscal_rep.vat

Check warning on line 140 in l10n_fr_intrastat_product/models/intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_fr_intrastat_product/models/intrastat_product_declaration.py#L140

Added line #L140 was not covered by tests
dpt = self._get_fr_department(inv_line, notedict)
line_vals["fr_department_id"] = dpt and dpt.id or False
return res
Expand Down

0 comments on commit 4903adf

Please sign in to comment.