diff --git a/addons/product/models/product_supplierinfo.py b/addons/product/models/product_supplierinfo.py index af0a94f6f2d..6bf474a2bfa 100644 --- a/addons/product/models/product_supplierinfo.py +++ b/addons/product/models/product_supplierinfo.py @@ -86,7 +86,8 @@ class SupplierInfo(models.Model): def _sanitize_vals(self, vals): """Sanitize vals to sync product variant & template on read/write.""" - if 'product_id' in vals and 'product_tmpl_id' not in vals: + # add product's product_tmpl_id if none present in vals + if vals.get('product_id') and not vals.get('product_tmpl_id'): product = self.env['product.product'].browse(vals['product_id']) vals['product_tmpl_id'] = product.product_tmpl_id.id diff --git a/addons/product/tests/test_seller.py b/addons/product/tests/test_seller.py index 42deb5ec410..7de18ed985f 100644 --- a/addons/product/tests/test_seller.py +++ b/addons/product/tests/test_seller.py @@ -146,3 +146,6 @@ class TestSeller(TransactionCase): }]) self.assertEqual(vendors, self.product_consu.seller_ids, "Sellers of a product should be listed in the product's seller_ids") + vendors.write({'product_id': False}) + self.assertEqual(vendors, self.product_consu.seller_ids, + "Setting the product_id to False shouldn't affect seller_ids.")