Skip to content
Permalink
Browse files

Apply new changes since rebase

  • Loading branch information...
tivisse committed Apr 19, 2019
1 parent 851b77b commit a22e7626de78e20ef5e482bfaec2edbb72a58435
@@ -164,14 +164,7 @@ def try_loading_for_current_company(self):
of accounts had been created for it yet.
"""
self.ensure_one()
# do not use `request.env` here, it can cause deadlocks
if request and request.session.uid:
current_user = self.env['res.users'].browse(request.uid)
company = current_user.company_id
else:
# fallback to company of current user, most likely __system__
# (won't work well for multi-company)
company = self.env.company_id
company = self.env.company_id
# If we don't have any chart of account on this company, install this chart of account
if not company.chart_template_id and not self.existing_accounting(company):
self.load_for_current_company(15.0, 15.0)
@@ -185,14 +178,7 @@ def load_for_current_company(self, sale_tax_rate, purchase_tax_rate):
rights.
"""
self.ensure_one()
# do not use `request.env` here, it can cause deadlocks
if request and request.session.uid:
current_user = self.env['res.users'].browse(request.uid)
company = current_user.company_id
else:
# fallback to company of current user, most likely __system__
# (won't work well for multi-company)
company = self.env.company_id
company = self.env.company_id
# Ensure everything is translated to the company's language, not the user's one.
self = self.with_context(lang=company.partner_id.lang)
if not self.env.user._is_admin():
@@ -5,7 +5,7 @@
<field name="name">Delivery Carrier multi-company</field>
<field name="model_id" ref="model_delivery_carrier"/>
<field name="global" eval="True"/>
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
<field name="domain_force"> ['|', ('company_id', 'in', allowed_company_ids), ('company_id', '=', False)]</field>
<field name="active" eval="False"/>
</record>
</data>
@@ -77,7 +77,7 @@
<field name="name">Time Off: multi company global rule</field>
<field name="model_id" ref="model_hr_leave"/>
<field name="global" eval="True"/>
<field name="domain_force">['|', ('holiday_status_id.company_id', '=', False), ('holiday_status_id.company_id', 'in', [user.company_id.id])]</field>
<field name="domain_force">['|', ('holiday_status_id.company_id', '=', False), ('holiday_status_id.company_id', 'in', allowed_company_ids)]</field>
</record>

<record id="hr_leave_allocation_rule_employee" model="ir.rule">
@@ -145,7 +145,7 @@
<field name="name">Time Off multi company rule</field>
<field name="model_id" ref="model_hr_leave_type"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','in',[user.company_id.id])]</field>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', allowed_company_ids)]</field>
</record>

</odoo>
@@ -51,13 +51,13 @@
<field name="name">Point Of Sale Order</field>
<field name="model_id" ref="model_pos_order" />
<field name="global" eval="True" />
<field name="domain_force">[('company_id', '=', user.company_id.id)]</field>
<field name="domain_force">[('company_id', 'in', allowed_company_ids)]</field>
</record>
<record id="rule_pos_session_multi_company" model="ir.rule">
<field name="name">Point Of Sale Session</field>
<field name="model_id" ref="model_pos_session" />
<field name="global" eval="True" />
<field name="domain_force">[('config_id.company_id', '=', user.company_id.id)]</field>
<field name="domain_force">[('config_id.company_id', 'in', allowed_company_ids)]</field>
</record>
<record id="rule_pos_config_multi_company" model="ir.rule">
<field name="name">Point Of Sale Config</field>
@@ -34,29 +34,29 @@
<field name="name" >Product multi-company</field>
<field name="model_id" ref="model_product_template"/>
<field name="global" eval="True"/>
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
<field name="domain_force"> ['|', ('company_id', 'in', allowed_company_ids), ('company_id', '=', False)]</field>
<field name="active" eval="False"/>
</record>

<record model="ir.rule" id="product_pricelist_comp_rule">
<field name="name">product pricelist company rule</field>
<field name="model_id" ref="model_product_pricelist"/>
<field name="global" eval="True"/>
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
<field name="domain_force"> ['|', ('company_id', 'in', allowed_company_ids), ('company_id', '=', False)]</field>
</record>

<record model="ir.rule" id="product_pricelist_item_comp_rule">
<field name="name">product pricelist item company rule</field>
<field name="model_id" ref="model_product_pricelist_item"/>
<field name="global" eval="True"/>
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
<field name="domain_force"> ['|', ('company_id', 'in', allowed_company_ids), ('company_id', '=', False)]</field>
</record>

<record model="ir.rule" id="product_supplierinfo_comp_rule">
<field name="name">product supplierinfo company rule</field>
<field name="model_id" ref="model_product_supplierinfo"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','=',user.company_id.id)]</field>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', allowed_company_ids)]</field>
</record>

</data>
@@ -211,6 +211,7 @@ def _make_access_error(self, operation, records):

# debug mode, provide more info
rules = self._get_failing(records, mode=operation).sudo()
# import pdb; pdb.set_trace()
return AccessError(_("""The requested operation ("%(operation)s" on "%(document_kind)s" (%(document_model)s)) was rejected because of the following rules:
%(rules_list)s
%(multi_company_warning)s

0 comments on commit a22e762

Please sign in to comment.
You can’t perform that action at this time.