Skip to content

Commit

Permalink
[13.0][FIX] Compatibility with multicompany
Browse files Browse the repository at this point in the history
- The mis.report.instance should allow to define as many
  companies as the user is allowed to operate on when logged.
- The company is only a required field if the flag 'multi_company' is not set.
  • Loading branch information
JordiBForgeFlow committed Oct 27, 2020
1 parent 38148d6 commit 1fe2deb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions mis_builder/models/mis_report_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def _compute_pivot_date(self):
comodel_name="res.company",
string="Company",
default=lambda self: self.env.company,
required=True,
required=False,
)
multi_company = fields.Boolean(
string="Multiple companies",
Expand All @@ -511,6 +511,7 @@ def _compute_pivot_date(self):
comodel_name="res.company",
string="Companies",
help="Select companies for which data will be searched.",
domain=lambda self: [("id", "in", self.env.companies.ids)]
)
query_company_ids = fields.Many2many(
comodel_name="res.company",
Expand Down Expand Up @@ -544,12 +545,10 @@ def _compute_pivot_date(self):
)
hide_analytic_filters = fields.Boolean(default=True)

@api.onchange("company_id", "multi_company")
@api.onchange("multi_company")
def _onchange_company(self):
if self.company_id and self.multi_company:
self.company_ids = self.env["res.company"].search(
[("id", "child_of", self.company_id.id)]
)
if self.multi_company:
self.company_id = False
else:
self.company_ids = False

Expand Down
2 changes: 2 additions & 0 deletions mis_builder/readme/newsfragments/327.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The mis.report.instance should allow to define as many companies as the user is allowed to operate on when logged.
The company is only a required field if the flag 'multi_company' is not set.
2 changes: 1 addition & 1 deletion mis_builder/security/mis_builder_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<field name="name">Mis Report Instance multi company</field>
<field name="model_id" ref="model_mis_report_instance" />
<field name="domain_force">
['|',('company_id','=',False),('company_id','in',company_ids)]
['|',('company_id','=',False),('company_id','in',company_ids), '|', ('company_ids', '=', False), ('company_ids', 'in', company_ids)]
</field>
</record>
</odoo>
2 changes: 1 addition & 1 deletion mis_builder/views/mis_report_instance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<field
name="company_id"
groups="base.group_multi_company"
attrs="{'required': [('multi_company', '=', False)]}"
/>
<field
name="multi_company"
Expand All @@ -172,7 +173,6 @@
name="company_ids"
groups="base.group_multi_company"
widget="many2many_tags"
domain="[('id', 'child_of', company_id)]"
attrs="{'invisible': [('multi_company', '=', False)]}"
/>
<field
Expand Down

0 comments on commit 1fe2deb

Please sign in to comment.