[FIX] delivery: products not shared

- Define 2 companies A and B. Delivery methods are linked to products in
  company A
- Deactivate 'Share product to all companies'
- Create a user B in Company B only
- As user B, create a SO and open the drop-down list for delivery
  methods

An access error is raised.

Delivery methods should follow the same record rules than the products
they are linked to.

opw-1815490
This commit is contained in:
Nicolas Martinelli
2018-03-06 10:02:44 +01:00
committed by Nicolas Martinelli
parent b466b3bc60
commit 037cfc9f67
4 changed files with 31 additions and 0 deletions
+1
View File
@@ -16,6 +16,7 @@ invoices from picking, the system is able to add and compute the shipping line.
'depends': ['sale_stock'],
'data': [
'security/ir.model.access.csv',
'security/delivery_security.xml',
'views/delivery_view.xml',
'views/partner_view.xml',
'views/product_template_view.xml',
+1
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import base_config_settings
import delivery_carrier
import delivery_price_rule
import product_template
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'
@api.multi
def set_auth_company_share_product(self):
self.ensure_one()
res = super(BaseConfigSettings, self).set_auth_company_share_product()
delivery_rule = self.env.ref('delivery.delivery_comp_rule', False)
if delivery_rule:
delivery_rule.write({'active': not bool(self.company_share_product)})
return res
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="delivery_comp_rule" model="ir.rule">
<field name="name">Delivery multi-company</field>
<field name="model_id" ref="model_delivery_carrier"/>
<field name="global" eval="True"/>
<field name="domain_force"> ['|',('product_id.company_id','=',user.company_id.id),('product_id.company_id','=',False)]</field>
<field name="active" eval="False"/>
</record>
</data>
</odoo>