Skip to content

Commit

Permalink
[IMP] l10n_es_aeat_mod369: Adapt code to changes on OSS taxes country…
Browse files Browse the repository at this point in the history
… value
  • Loading branch information
aritzolea committed Dec 22, 2023
1 parent c98470f commit 4e73d20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 8 additions & 6 deletions l10n_es_aeat_mod369/models/mod369.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _compute_total_amount(self):
inverse_name="report_id",
domain=[
("service_type", "=", "services"),
("oss_country_id.code", "=", "ES"),
("country_id.code", "=", "ES"),
("is_page_8_line", "=", False),
("is_refund", "=", False),
],
Expand All @@ -59,7 +59,7 @@ def _compute_total_amount(self):
inverse_name="report_id",
domain=[
("service_type", "=", "goods"),
("oss_country_id.code", "=", "ES"),
("country_id.code", "=", "ES"),
("is_page_8_line", "=", False),
("is_refund", "=", False),
],
Expand Down Expand Up @@ -260,14 +260,14 @@ def calculate(self):
country = mod369_line.country_id
oss_country = mod369_line.oss_country_id
tax = mod369_line.oss_tax_id
outside_spain = bool(oss_country.code != "ES")
outside_spain = bool(country.code != "ES")
key_country = "OUT-ES" if outside_spain else "ES"
mod369_line.oss_sequence = lines_index[tax.service_type][key_country]
lines_index[tax.service_type][key_country] += 1
if len(move_lines) > 0:
# page 3, 4, 5 or 6
key = "{}{}{}{}".format(
country.id,
oss_country.id,
tax.id,
tax.service_type,
outside_spain,
Expand All @@ -286,7 +286,7 @@ def calculate(self):
country_groups[key]["mod369_line_ids"] += [(4, mod369_line.id)]
# page 8
country_groups.setdefault(
country.id,
oss_country.id,
{
"country_id": country.id,
"oss_country_id": oss_country.id,
Expand All @@ -297,7 +297,9 @@ def calculate(self):
"is_page_8_line": True,
},
)
country_groups[country.id]["mod369_line_ids"] += [(4, mod369_line.id)]
country_groups[oss_country.id]["mod369_line_ids"] += [
(4, mod369_line.id)
]
for mline in ref_move_lines:
orig_move = mline.move_id.reversed_entry_id
refund_fiscal_year = orig_move.date.year
Expand Down
6 changes: 3 additions & 3 deletions l10n_es_aeat_mod369/models/mod369_line_grouped.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _compute_totals(self):
group_keys[line.map_line_id.field_type] += amount
if not group.is_page_8_line or line.map_line_id.field_type != "amount":
continue
if line.oss_country_id.code == "ES":
if line.country_id.code == "ES":
if line.service_type == "services":
group_keys["page_3_total"] += amount
elif line.service_type == "goods":
Expand Down Expand Up @@ -131,11 +131,11 @@ def _compute_totals(self):
total_deposit = fields.Float(string="Total to deposit ES")
total_return = fields.Float(string="Total to return EM")

@api.depends("country_id", "country_id.code")
@api.depends("oss_country_id", "oss_country_id.code")
def _compute_country_code(self):
for line in self:
line.country_code = self.env["res.partner"]._map_aeat_country_iso_code(
line.country_id
line.oss_country_id
)

def get_calculated_move_lines(self):
Expand Down
2 changes: 2 additions & 0 deletions l10n_es_aeat_mod369/tests/test_l10n_es_aeat_mod369.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class TestL10nEsAeatMod369Base(TestL10nEsAeatModBase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.company.country_id = cls.env.ref("base.es").id
cls.company.account_fiscal_country_id = cls.env.ref("base.es").id
general_tax = cls.env.ref(
"l10n_es.%s_account_tax_template_s_iva21b" % cls.company.id
)
Expand Down

0 comments on commit 4e73d20

Please sign in to comment.