Skip to content

Commit

Permalink
Merge pull request #462 from ecosoft-odoo/16.0-fix-budget_control-adj…
Browse files Browse the repository at this point in the history
…ust_multi_company

[16.0][IMP] budget_control: multi-company budget adjustment
  • Loading branch information
Saran440 authored Sep 24, 2024
2 parents e4813d5 + 8811072 commit 31dc5c0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions budget_control/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"data/sequence_data.xml",
"security/budget_control_security_groups.xml",
"security/budget_control_rules.xml",
"security/budget_adjustment_rules.xml",
"security/ir.model.access.csv",
"wizards/generate_budget_control_view.xml",
"wizards/analytic_budget_info_view.xml",
Expand Down
1 change: 0 additions & 1 deletion budget_control/models/budget_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class BudgetControl(models.Model):
)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
default=lambda self: self.env.company,
required=True,
readonly=True,
Expand Down
19 changes: 18 additions & 1 deletion budget_control/models/budget_move_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,19 @@ class BudgetMoveAdjustment(models.Model):
states={"draft": [("readonly", False)]},
tracking=True,
)
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company,
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
index=True,
)
currency_id = fields.Many2one(
comodel_name="res.currency",
default=lambda self: self.env.user.company_id.currency_id,
related="company_id.currency_id",
store=True,
states={"draft": [("readonly", False)]},
)
state = fields.Selection(
[
Expand Down Expand Up @@ -144,6 +154,13 @@ class BudgetMoveAdjustmentItem(models.Model):
account_id = fields.Many2one(
comodel_name="account.account",
required=True,
index=True,
)
company_id = fields.Many2one(
related="adjust_id.company_id",
store=True,
readonly=True,
index=True,
)
currency_id = fields.Many2one(
related="adjust_id.currency_id",
Expand Down
13 changes: 13 additions & 0 deletions budget_control/security/budget_adjustment_rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2022 Akretion France (http://www.akretion.com/)
@author Alexis de Lattre <[email protected]>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
-->
<odoo noupdate="1">
<record id="budget_adjustment_rule" model="ir.rule">
<field name="name">Budget Adjustment multi-company</field>
<field name="model_id" ref="model_budget_move_adjustment" />
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
</odoo>
5 changes: 5 additions & 0 deletions budget_control/views/budget_move_adjustment_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<tree>
<field name="name" />
<field name="description" />
<field name="company_id" groups="base.group_multi_company" />
<field
name="state"
widget="badge"
Expand Down Expand Up @@ -100,6 +101,10 @@
<group name="budget_move_adjustment_right">
<field name="create_uid" readonly="1" />
<field name="create_date" readonly="1" />
<field
name="company_id"
groups="base.group_multi_company"
/>
<field
name="currency_id"
groups="base.group_multi_currency"
Expand Down

0 comments on commit 31dc5c0

Please sign in to comment.