From 03925faa48e4a078cf9a6910b4e0fe4324adff20 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Mon, 2 Sep 2019 09:51:07 +0000 Subject: [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 --- addons/product/models/product.py | 10 ++++++---- addons/product/security/product_security.xml | 7 +++++++ addons/product/views/product_views.xml | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 7a6ba5f1a67..7f6113fc48a 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -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( diff --git a/addons/product/security/product_security.xml b/addons/product/security/product_security.xml index 8b6556304a5..6da657fca1a 100644 --- a/addons/product/security/product_security.xml +++ b/addons/product/security/product_security.xml @@ -59,5 +59,12 @@ ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + product packaging company rule + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + diff --git a/addons/product/views/product_views.xml b/addons/product/views/product_views.xml index 525424c79c6..7941bb01f90 100644 --- a/addons/product/views/product_views.xml +++ b/addons/product/views/product_views.xml @@ -493,6 +493,7 @@ + @@ -530,6 +531,7 @@ + -- cgit v1.2.3