Skip to content

Commit

Permalink
[MIG] account_analytic_tag: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rov-adhoc committed Mar 26, 2024
1 parent 65292ed commit 21d8bf5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion account_analytic_tag/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 9 additions & 2 deletions account_analytic_tag/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion account_analytic_tag/security/analytic_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
</record>
</data>
<data noupdate="0">
<data>
<record id="group_analytic_tags" model="res.groups">
<field name="name">Analytic Accounting Tags</field>
<field name="category_id" ref="base.module_category_hidden" />
Expand Down
3 changes: 1 addition & 2 deletions account_analytic_tag/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions account_analytic_tag/tests/test_account_analytic_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions account_analytic_tag/views/account_analytic_tag_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="display_name" invisible="1" />
<field name="display_name" column_invisible="True" />
<field name="account_analytic_id" />
<field name="color" widget="color_picker" />
<field name="company_id" groups="base.group_multi_company" />
Expand All @@ -22,7 +22,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<group>
<group>
Expand Down
2 changes: 1 addition & 1 deletion account_analytic_tag/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='track_costs_revenues']" position="after">
<xpath expr="//setting[@id='track_costs_revenues']" position="after">
<div
class="col-12 col-lg-6 o_setting_box"
id="tag_analytic_entries"
Expand Down

0 comments on commit 21d8bf5

Please sign in to comment.