Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][PORT] 630 from 16.0 #659

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion mis_builder_budget/models/mis_budget_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,30 @@ class MisBudgetItem(models.Model):
)
)

company_id = fields.Many2one(
comodel_name="res.company",
compute="_compute_company_id",
store=True,
readonly=False,
)
budget_company_id = fields.Many2one(
string="#Technical field: Budget Company", related="budget_id.company_id"
)

@api.depends("budget_id.company_id")
def _compute_company_id(self):
for rec in self:
rec.company_id = rec.budget_id.company_id

def _prepare_overlap_domain(self):
"""Prepare a domain to check for overlapping budget items."""
domain = super()._prepare_overlap_domain()
domain.extend([("kpi_expression_id", "=", self.kpi_expression_id.id)])
domain.extend(
[
("kpi_expression_id", "=", self.kpi_expression_id.id),
("company_id", "=", self.company_id.id),
]
)
return domain

@api.constrains(
Expand All @@ -31,6 +51,7 @@ def _prepare_overlap_domain(self):
"date_to",
"budget_id",
"kpi_expression_id",
"company_id",
)
def _check_dates(self):
super()._check_dates()
Expand Down
14 changes: 14 additions & 0 deletions mis_builder_budget/models/mis_report_instance_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.osv.expression import AND

SRC_MIS_BUDGET = "mis_budget"
SRC_MIS_BUDGET_BY_ACCOUNT = "mis_budget_by_account"
Expand Down Expand Up @@ -69,4 +70,17 @@ def _get_additional_budget_item_filter(self):
compatible with mis.budget.item."""
self.ensure_one()
filters = self._get_additional_move_line_filter()

query_companies = self.report_instance_id.query_company_ids
filters = AND(
[
filters,
[
"|",
("company_id", "in", query_companies.ids),
("company_id", "=", False),
],
]
)

return filters
2 changes: 1 addition & 1 deletion mis_builder_budget/security/mis_budget_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<field name="name">mis.budget.item multi company</field>
<field name="model_id" ref="model_mis_budget_item" />
<field name="domain_force">
['|',('budget_id.company_id','=',False),('budget_id.company_id','in',company_ids)]
['|',('company_id','=',False),('company_id','in',company_ids)]
</field>
</record>
</odoo>
3 changes: 3 additions & 0 deletions mis_builder_budget/tests/test_mis_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def test_drilldown(self):
("date_to", ">=", datetime.date(2017, 1, 1)),
("kpi_expression_id", "=", self.expr1.id),
("budget_id", "=", self.budget.id),
"|",
("company_id", "in", [self.env.company.id]),
("company_id", "=", False),
],
)

Expand Down
2 changes: 2 additions & 0 deletions mis_builder_budget/views/mis_budget_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
<field name="report_id" column_invisible="1" />
<field name="budget_date_from" column_invisible="1" />
<field name="budget_date_to" column_invisible="1" />
<field name="budget_company_id" column_invisible="1" />
<field name="kpi_expression_id" />
<field name="date_range_id" />
<field name="date_from" />
<field name="date_to" />
<field name="amount" />
<field name="company_id" readonly="budget_company_id" />
</tree>
</field>
</record>
Expand Down
Loading