[REF] product: multi company

Add an optional company_id on product.packaging to be able to share
of restrict them, similar to what's done for product.product.

task-1985992
This commit is contained in:
Simon Lejeune
2019-09-03 15:05:04 +00:00
parent 13d6f64a73
commit 03925faa48
3 changed files with 15 additions and 4 deletions
+6 -4
View File
@@ -697,13 +697,15 @@ class ProductPackaging(models.Model):
_name = "product.packaging"
_description = "Product Packaging"
_order = 'sequence'
_check_company_auto = True
name = fields.Char('Package Type', required=True)
sequence = fields.Integer('Sequence', default=1, help="The first in the sequence is the default one.")
product_id = fields.Many2one('product.product', string='Product')
product_id = fields.Many2one('product.product', string='Product', check_company=True)
qty = fields.Float('Contained Quantity', help="Quantity of products contained in the packaging.")
barcode = fields.Char('Barcode', copy=False, help="Barcode used for packaging identification. Scan this packaging barcode from a transfer in the Barcode app to move all the contained units")
product_uom_id = fields.Many2one('uom.uom', related='product_id.uom_id', readonly=True)
company_id = fields.Many2one('res.company', 'Company', index=True)
class SupplierInfo(models.Model):
@@ -714,7 +716,7 @@ class SupplierInfo(models.Model):
name = fields.Many2one(
'res.partner', 'Vendor',
ondelete='cascade', required=True,
help="Vendor of this product")
help="Vendor of this product", check_company=True)
product_name = fields.Char(
'Vendor Product Name',
help="This vendor's product name will be used when printing a request for quotation. Keep empty to use the internal one.")
@@ -743,10 +745,10 @@ class SupplierInfo(models.Model):
date_start = fields.Date('Start Date', help="Start date for this vendor price")
date_end = fields.Date('End Date', help="End date for this vendor price")
product_id = fields.Many2one(
'product.product', 'Product Variant',
'product.product', 'Product Variant', check_company=True,
help="If not set, the vendor price will apply to all variants of this product.")
product_tmpl_id = fields.Many2one(
'product.template', 'Product Template',
'product.template', 'Product Template', check_company=True,
index=True, ondelete='cascade')
product_variant_count = fields.Integer('Variant Count', related='product_tmpl_id.product_variant_count', readonly=False)
delay = fields.Integer(
@@ -59,5 +59,12 @@
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>
<record model="ir.rule" id="product_packaging_comp_rule">
<field name="name">product packaging company rule</field>
<field name="model_id" ref="model_product_packaging"/>
<field name="global" eval="True"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>
</data>
</odoo>
+2
View File
@@ -493,6 +493,7 @@
<field name="name" string="Packaging"/>
<field name="qty"/>
<field name="product_uom_id" options="{'no_open': True, 'no_create': True}" groups="uom.group_uom"/>
<field name="company_id" group="base.group_multi_company"/>
</tree>
</field>
</record>
@@ -530,6 +531,7 @@
<field name="product_uom_id" options="{'no_open': True, 'no_create': True}" groups="uom.group_uom"/>
</div>
<field name="barcode"/>
<field name="company_id" group="base.group_multi_company"/>
</group>
</group>
</sheet>