From 21d8bf526901993e6358baead1916a06ad7b1739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roc=C3=ADo=20Vega?= Date: Tue, 26 Mar 2024 10:35:15 -0300 Subject: [PATCH] [MIG] account_analytic_tag: Migration to 17.0 --- account_analytic_tag/__manifest__.py | 2 +- account_analytic_tag/models/account_move_line.py | 11 +++++++++-- account_analytic_tag/security/analytic_security.xml | 2 +- account_analytic_tag/tests/common.py | 3 +-- .../tests/test_account_analytic_tag.py | 5 +++++ .../views/account_analytic_tag_views.xml | 4 ++-- .../views/res_config_settings_views.xml | 2 +- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/account_analytic_tag/__manifest__.py b/account_analytic_tag/__manifest__.py index 636540607f..bd45ff1e2f 100644 --- a/account_analytic_tag/__manifest__.py +++ b/account_analytic_tag/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Account Analytic Tag", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "author": "Tecnativa, Odoo Community Association (OCA)", "category": "Account", "website": "https://github.com/OCA/account-analytic", diff --git a/account_analytic_tag/models/account_move_line.py b/account_analytic_tag/models/account_move_line.py index f4647a6bc1..ad8d212e22 100644 --- a/account_analytic_tag/models/account_move_line.py +++ b/account_analytic_tag/models/account_move_line.py @@ -15,9 +15,16 @@ def _prepare_analytic_lines(self): if self.analytic_tag_ids: for val in vals: account_id = val.get("account_id") + if not account_id: + account_field_name = next( + (key for key in val.keys() if key.startswith("x_plan")), None + ) + account_id = val.get(account_field_name) tags = self.analytic_tag_ids.filtered( - lambda x: not x.account_analytic_id - or x.account_analytic_id.id == account_id + lambda x, account_id=account_id: ( + not x.account_analytic_id + or x.account_analytic_id.id == account_id + ) ) val.update({"tag_ids": [(6, 0, tags.ids)]}) return vals diff --git a/account_analytic_tag/security/analytic_security.xml b/account_analytic_tag/security/analytic_security.xml index a7c4c4b4e8..06feff0ef8 100644 --- a/account_analytic_tag/security/analytic_security.xml +++ b/account_analytic_tag/security/analytic_security.xml @@ -10,7 +10,7 @@ >['|',('company_id','=',False),('company_id', 'in', company_ids)] - + Analytic Accounting Tags diff --git a/account_analytic_tag/tests/common.py b/account_analytic_tag/tests/common.py index e32b0b2809..cb391c3f85 100644 --- a/account_analytic_tag/tests/common.py +++ b/account_analytic_tag/tests/common.py @@ -21,8 +21,7 @@ def setUpClass(cls): cls.user = new_test_user( cls.env, login="test-analytic-tag-user", - groups="%s,%s,%s" - % ( + groups="{},{},{}".format( "account.group_account_invoice", "analytic.group_analytic_accounting", "account_analytic_tag.group_analytic_tags", diff --git a/account_analytic_tag/tests/test_account_analytic_tag.py b/account_analytic_tag/tests/test_account_analytic_tag.py index da72a97e4e..0e4c4c4c26 100644 --- a/account_analytic_tag/tests/test_account_analytic_tag.py +++ b/account_analytic_tag/tests/test_account_analytic_tag.py @@ -20,10 +20,15 @@ def setUpClass(cls): with invoice_form.invoice_line_ids.new() as line_form: line_form.product_id = cls.product_a line_form.analytic_tag_ids.add(cls.account_analytic_tag_a) + line_form.analytic_distribution = {cls.analytic_account_a.id: 100} with invoice_form.invoice_line_ids.new() as line_form: line_form.product_id = cls.product_b line_form.analytic_tag_ids.add(cls.account_analytic_tag_a) line_form.analytic_tag_ids.add(cls.account_analytic_tag_b) + line_form.analytic_distribution = { + cls.analytic_account_a.id: 50, + cls.analytic_account_b.id: 50, + } cls.invoice = invoice_form.save() cls.line_a = cls.invoice.invoice_line_ids.filtered( lambda x: x.product_id == cls.product_a diff --git a/account_analytic_tag/views/account_analytic_tag_views.xml b/account_analytic_tag/views/account_analytic_tag_views.xml index d983bf4c66..9345ef9de5 100644 --- a/account_analytic_tag/views/account_analytic_tag_views.xml +++ b/account_analytic_tag/views/account_analytic_tag_views.xml @@ -5,7 +5,7 @@ - + @@ -22,7 +22,7 @@ name="web_ribbon" title="Archived" bg_color="bg-danger" - attrs="{'invisible': [('active', '=', True)]}" + invisible="active" /> diff --git a/account_analytic_tag/views/res_config_settings_views.xml b/account_analytic_tag/views/res_config_settings_views.xml index 86f83958fb..032c7a87d2 100644 --- a/account_analytic_tag/views/res_config_settings_views.xml +++ b/account_analytic_tag/views/res_config_settings_views.xml @@ -7,7 +7,7 @@ res.config.settings - +