diff --git a/account_analytic_tag/hooks.py b/account_analytic_tag/hooks.py index 8196237cef..6e53d5ed46 100644 --- a/account_analytic_tag/hooks.py +++ b/account_analytic_tag/hooks.py @@ -2,10 +2,10 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -def pre_init_hook(cr): +def pre_init_hook(env): # In case you come from a previous version, reuse the security group, and avoid # to crash due to 2 groups with the same name. - cr.execute( + env.cr.execute( """UPDATE ir_model_data SET module='account_analytic_tag' WHERE module='analytic' and name='group_analytic_tags' diff --git a/account_analytic_tag/models/account_move_line.py b/account_analytic_tag/models/account_move_line.py index bc74608ba0..184144b715 100644 --- a/account_analytic_tag/models/account_move_line.py +++ b/account_analytic_tag/models/account_move_line.py @@ -14,7 +14,9 @@ def _prepare_analytic_lines(self): vals = super()._prepare_analytic_lines() if self.analytic_tag_ids: for val in vals: - account_id = val.get("account_id") + account_id = [ + value for key, value in val.items() if key.startswith("x_plan") + ][0] tags = self.analytic_tag_ids.filtered( lambda x, y=account_id: not x.account_analytic_id or x.account_analytic_id.id == y diff --git a/account_analytic_tag/tests/common.py b/account_analytic_tag/tests/common.py index 9c57f298f8..3b00bf50bb 100644 --- a/account_analytic_tag/tests/common.py +++ b/account_analytic_tag/tests/common.py @@ -21,11 +21,16 @@ def setUpClass(cls): cls.user = new_test_user( cls.env, login="test-analytic-tag-user", - groups="account.group_account_invoice \ - analytic.group_analytic_accounting \ + groups="account.group_account_invoice, analytic.group_analytic_accounting, \ account_analytic_tag.group_analytic_tags", ) # ==== For Accounting ==== + cls.default_company_id = cls.env["res.company"].browse(1) + # Set chart template + cls.default_company_id._chart_template_selection() + cls.default_journal_id = cls.env["account.journal"].create( + {"name": "Test Journal", "type": "sale", "code": "TST"} + ) cls.default_plan = cls.env["account.analytic.plan"].create({"name": "Default"}) cls.analytic_account_a = cls.env["account.analytic.account"].create( { diff --git a/account_analytic_tag/views/account_analytic_tag_views.xml b/account_analytic_tag/views/account_analytic_tag_views.xml index d983bf4c66..4d4f5960ab 100644 --- a/account_analytic_tag/views/account_analytic_tag_views.xml +++ b/account_analytic_tag/views/account_analytic_tag_views.xml @@ -22,7 +22,7 @@ name="web_ribbon" title="Archived" bg_color="bg-danger" - attrs="{'invisible': [('active', '=', True)]}" + invisible="active == True" /> 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 - +