From 62e72ca1215946cab10b2358e7a370f7c8df8771 Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Wed, 15 Sep 2021 12:19:29 +0000 Subject: [PATCH] [FIX] account, l10n_eu_oss: make OSS report work with cash basis OSS taxes Before this fix, a cash basis OSS tax used together with a product using the "non-EU origin" tag didn't appear properly in the OSS import report. This was due to the fact the product tag was not copied on the cash basis move: it only appeared on the invoice, on non exigible lines. To fix that, we make the choice to keep the product tag as markup on the invoice, and to copy it to the cash basis lines created from move lines containing this tag. We therefore need a non-ambiguous way to identify account.account.tag objects that are used on products, since we don't want to copy tags used by taxes. Hence, we introduct a new value for the 'applicability' field of account.account.tag, limitating their use to products. closes odoo/odoo#76626 X-original-commit: 0dd712b876844c3e342447e4cf26b324fcaffc37 Related: odoo/enterprise#20916 Signed-off-by: Laurent Smet Signed-off-by: oco-odoo --- addons/account/models/account_account_tag.py | 2 +- addons/account/models/account_partial_reconcile.py | 8 ++++++-- addons/account/models/product.py | 2 +- addons/account/views/account_account_views.xml | 2 +- addons/account/views/account_chart_template_views.xml | 2 +- addons/l10n_eu_oss/data/account_account_tag.xml | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/account/models/account_account_tag.py b/addons/account/models/account_account_tag.py index fb0326d3baa..94366f9a115 100644 --- a/addons/account/models/account_account_tag.py +++ b/addons/account/models/account_account_tag.py @@ -8,7 +8,7 @@ class AccountAccountTag(models.Model): _description = 'Account Tag' name = fields.Char('Tag Name', required=True) - applicability = fields.Selection([('accounts', 'Accounts'), ('taxes', 'Taxes')], required=True, default='accounts') + applicability = fields.Selection([('accounts', 'Accounts'), ('taxes', 'Taxes'), ('products', 'Products')], required=True, default='accounts') color = fields.Integer('Color Index') active = fields.Boolean(default=True, help="Set active to false to hide the Account Tag without removing it.") tax_report_line_ids = fields.Many2many(string="Tax Report Lines", comodel_name='account.tax.report.line', relation='account_tax_report_line_tags_rel', help="The tax report lines using this tag") diff --git a/addons/account/models/account_partial_reconcile.py b/addons/account/models/account_partial_reconcile.py index 4885e649797..07f807e710d 100644 --- a/addons/account/models/account_partial_reconcile.py +++ b/addons/account/models/account_partial_reconcile.py @@ -232,6 +232,9 @@ class AccountPartialReconcile(models.Model): account = base_line.company_id.account_cash_basis_base_account_id or base_line.account_id tax_ids = base_line.tax_ids.filtered(lambda x: x.tax_exigibility == 'on_payment') is_refund = base_line.belongs_to_refund() + tax_tags = tax_ids.get_tax_tags(is_refund, 'base') + product_tags = base_line.tax_tag_ids.filtered(lambda x: x.applicability == 'products') + all_tags = tax_tags + product_tags return { 'name': base_line.move_id.name, @@ -242,7 +245,7 @@ class AccountPartialReconcile(models.Model): 'partner_id': base_line.partner_id.id, 'account_id': account.id, 'tax_ids': [Command.set(tax_ids.ids)], - 'tax_tag_ids': [Command.set(tax_ids.get_tax_tags(is_refund, 'base').ids)], + 'tax_tag_ids': [Command.set(all_tags.ids)], 'tax_tag_invert': base_line.tax_tag_invert, } @@ -277,7 +280,8 @@ class AccountPartialReconcile(models.Model): ''' tax_ids = tax_line.tax_ids.filtered(lambda x: x.tax_exigibility == 'on_payment') base_tags = tax_ids.get_tax_tags(tax_line.tax_repartition_line_id.refund_tax_id, 'base') - all_tags = base_tags + tax_line.tax_repartition_line_id.tag_ids + product_tags = tax_line.tax_tag_ids.filtered(lambda x: x.applicability == 'products') + all_tags = base_tags + tax_line.tax_repartition_line_id.tag_ids + product_tags return { 'name': tax_line.name, diff --git a/addons/account/models/product.py b/addons/account/models/product.py index 87f02749c38..9ae864be1b1 100644 --- a/addons/account/models/product.py +++ b/addons/account/models/product.py @@ -39,7 +39,7 @@ class ProductTemplate(models.Model): account_tag_ids = fields.Many2many( string="Account Tags", comodel_name='account.account.tag', - domain="[('tax_report_line_ids', '=', False), ('applicability', '=', 'taxes')]", + domain="[('applicability', '=', 'products')]", help="Tags to be set on the base and tax journal items created for this product.") def _get_product_accounts(self): diff --git a/addons/account/views/account_account_views.xml b/addons/account/views/account_account_views.xml index c89bf16a764..49d826c320b 100644 --- a/addons/account/views/account_account_views.xml +++ b/addons/account/views/account_account_views.xml @@ -61,7 +61,7 @@ - + diff --git a/addons/account/views/account_chart_template_views.xml b/addons/account/views/account_chart_template_views.xml index 6aa16900233..fa0fb6d410c 100644 --- a/addons/account/views/account_chart_template_views.xml +++ b/addons/account/views/account_chart_template_views.xml @@ -86,7 +86,7 @@ - + diff --git a/addons/l10n_eu_oss/data/account_account_tag.xml b/addons/l10n_eu_oss/data/account_account_tag.xml index 7783c129262..46046cbb356 100644 --- a/addons/l10n_eu_oss/data/account_account_tag.xml +++ b/addons/l10n_eu_oss/data/account_account_tag.xml @@ -9,7 +9,7 @@ non-EU origin - taxes + products