Skip to content

Commit

Permalink
[ADD] fieldservice_account_analytic: Add group when installed
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarRetes committed Dec 5, 2024
1 parent 3dcd910 commit b7ce772
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion fieldservice_account_analytic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

from . import models
from . import wizard
from .init_hook import pre_init_hook
from .init_hook import pre_init_hook, post_init_hook
1 change: 1 addition & 0 deletions fieldservice_account_analytic/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"demo/fsm_location.xml",
],
"pre_init_hook": "pre_init_hook",
"post_init_hook": "post_init_hook",
"license": "AGPL-3",
"development_status": "Beta",
"maintainers": [
Expand Down
12 changes: 12 additions & 0 deletions fieldservice_account_analytic/init_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@ def pre_init_hook(env):
"""UPDATE "fsm_location" SET customer_id = owner_id
WHERE customer_id IS NULL;"""
)


def post_init_hook(env):
group_analytic_accounting = env.ref(
"analytic.group_analytic_accounting", raise_if_not_found=False
)

if group_analytic_accounting:
users = env["res.users"].search([])

for user in users:
user.write({"groups_id": [(4, group_analytic_accounting.id)]})
9 changes: 5 additions & 4 deletions fieldservice_account_analytic/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ def create(self, vals_list):
}
)
record.analytic_account_id = analytic_account

Check warning on line 78 in fieldservice_account_analytic/models/fsm_order.py

View check run for this annotation

Codecov / codecov/patch

fieldservice_account_analytic/models/fsm_order.py#L78

Added line #L78 was not covered by tests

if "contractor_cost_ids" in vals:
for line in record.contractor_cost_ids:
line.analytic_distribution = line._default_analytic_distribution()
if "contractor_cost_ids" in vals:
for line in record.contractor_cost_ids:
line.analytic_distribution = (

Check warning on line 81 in fieldservice_account_analytic/models/fsm_order.py

View check run for this annotation

Codecov / codecov/patch

fieldservice_account_analytic/models/fsm_order.py#L81

Added line #L81 was not covered by tests
line._default_analytic_distribution()
)

return record
9 changes: 0 additions & 9 deletions fieldservice_account_analytic/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@
<field name="fsm_filter_location_by_contact" />
</setting>
</xpath>
<xpath expr="//block[@name='mapping_setting_container']" position="after">
<block title="Accounting" name="accounting_setting_container">
<setting
help="Manage analytic account for orders, locations and routes."
>
<field name="group_analytic_accounting" />
</setting>
</block>
</xpath>
</field>
</record>
</odoo>

0 comments on commit b7ce772

Please sign in to comment.