[FIX] product: set barcode on archived product
It is currently not possible to write the barcode of an archived product template. The inverse method does not consider case where the variant of the template is archived OPW-3109967 closes odoo/odoo#110697 X-original-commit: 968d0dff823f8e5d0871feaf8b09233fbb91b4de Signed-off-by: Adrien Widart <awt@odoo.com>
This commit is contained in:
@@ -212,8 +212,13 @@ class ProductTemplate(models.Model):
|
||||
(field name must be identical between product.product & product.template models)
|
||||
"""
|
||||
for template in self:
|
||||
if len(template.product_variant_ids) == 1:
|
||||
count = len(template.product_variant_ids)
|
||||
if count == 1:
|
||||
template.product_variant_ids[fname] = template[fname]
|
||||
elif count == 0:
|
||||
archived_variants = self.with_context(active_test=False).product_variant_ids
|
||||
if len(archived_variants) == 1:
|
||||
archived_variants[fname] = template[fname]
|
||||
|
||||
@api.depends_context('company')
|
||||
@api.depends('product_variant_ids.standard_price')
|
||||
|
||||
@@ -1186,6 +1186,19 @@ class TestVariantsArchive(ProductVariantsCommon):
|
||||
|
||||
Product._revert_method('unlink')
|
||||
|
||||
def test_set_barcode(self):
|
||||
tmpl = self.product.product_tmpl_id
|
||||
tmpl.barcode = '123'
|
||||
self.assertEqual(tmpl.barcode, '123')
|
||||
self.assertEqual(self.product.barcode, '123')
|
||||
|
||||
tmpl.toggle_active()
|
||||
|
||||
tmpl.barcode = '456'
|
||||
tmpl.invalidate_recordset(fnames=['barcode'])
|
||||
self.assertEqual(tmpl.barcode, '456')
|
||||
self.assertEqual(self.product.barcode, '456')
|
||||
|
||||
def _update_color_vars(self, ptal):
|
||||
self.ptal_color = ptal
|
||||
self.assertEqual(self.ptal_color.attribute_id, self.color_attribute)
|
||||
|
||||
Reference in New Issue
Block a user