[REF] account,l10n_eu_oss: query tag easily

The aimf of this commit is to make the query of a specific tag with a
specific sign easier by avoiding all the filtering in
`expression._get_tax_tags().filtered(lambda t: t.tax_negate)`

With this commit, we just leverage the existing filtering on domain to
only get the desired tag.

no-task

closes odoo/odoo#117167

X-original-commit: 6eb53a3802d24e283b8334b6f245ffe87dddcbe8
Related: odoo/enterprise#39044
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
This commit is contained in:
Brice bib Bartoletti
2023-03-30 16:23:10 +02:00
parent 1adaaba90e
commit 9e949bb0bf
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -605,7 +605,7 @@ class AccountReportExpression(models.Model):
return totals_by_code
def _get_matching_tags(self):
def _get_matching_tags(self, sign=None):
""" Returns all the signed account.account.tags records whose name matches any of the formulas of the tax_tags expressions contained in self.
"""
tag_expressions = self.filtered(lambda x: x.engine == 'tax_tags')
@@ -615,7 +615,7 @@ class AccountReportExpression(models.Model):
or_domains = []
for tag_expression in tag_expressions:
country = tag_expression.report_line_id.report_id.country_id
or_domains.append(self.env['account.account.tag']._get_tax_tags_domain(tag_expression.formula, country.id))
or_domains.append(self.env['account.account.tag']._get_tax_tags_domain(tag_expression.formula, country.id, sign))
return self.env['account.account.tag'].with_context(active_test=False).search(osv.expression.OR(or_domains))
+1 -1
View File
@@ -185,7 +185,7 @@ class TaxReportTest(AccountTestInvoicingCommon):
"""
tag_name = "55b"
tax_report_line = self._create_basic_tax_report_line(self.tax_report_1, "Line 55 bis", tag_name)
test_tag = tax_report_line.expression_ids._get_matching_tags().filtered(lambda tag: not tag.tax_negate)
test_tag = tax_report_line.expression_ids._get_matching_tags("+")
self.env['account.tax.group'].create({
'name': 'Tax group',
'country_id': self.tax_report_1.country_id.id,
+1 -1
View File
@@ -147,7 +147,7 @@ class Company(models.Model):
for repartition_line_key, tag_xml_id in tag_for_country.items():
tag = self.env.ref(tag_xml_id) if tag_xml_id else self.env['account.account.tag']
if tag and tag._name == "account.report.expression":
tag = tag._get_matching_tags().filtered(lambda t: not t.tax_negate)
tag = tag._get_matching_tags("+")
mapping[repartition_line_key] = tag + oss_tag
return mapping