From 96216c3d13cb69347aa836d167d4b92f4b6ce4a3 Mon Sep 17 00:00:00 2001 From: Cybrosys Technologies Date: Mon, 19 May 2025 16:12:04 +0530 Subject: [PATCH] May 19: [FIX] Bug fixed 'multi_barcodes_pos' --- multi_barcodes_pos/doc/RELEASE_NOTES.md | 7 ++++++- multi_barcodes_pos/models/product_product.py | 7 ++++--- multi_barcodes_pos/models/product_template.py | 16 +++++++++------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/multi_barcodes_pos/doc/RELEASE_NOTES.md b/multi_barcodes_pos/doc/RELEASE_NOTES.md index 362e60432..1269d8597 100755 --- a/multi_barcodes_pos/doc/RELEASE_NOTES.md +++ b/multi_barcodes_pos/doc/RELEASE_NOTES.md @@ -13,4 +13,9 @@ #### 01.10.2024 #### Version 17.0.1.0.2 ##### BUG FIX -- Added an alert and fix issue of multiple barcode \ No newline at end of file +- Added an alert and fix issue of multiple barcode + +#### 19.05.2025 +#### Version 17.0.1.0.3 +##### BUG FIX +- Fixed a bug where updating the product template caused the barcodes of all variants to be assigned to the first variant, resulting in the removal of barcodes from the other variants. diff --git a/multi_barcodes_pos/models/product_product.py b/multi_barcodes_pos/models/product_product.py index f0b9ef536..47c9c53d6 100755 --- a/multi_barcodes_pos/models/product_product.py +++ b/multi_barcodes_pos/models/product_product.py @@ -50,7 +50,8 @@ class ProductProduct(models.Model): the associated multi-barcode product template. """ res = super(ProductProduct, self).write(vals) - self.product_multi_barcodes_ids.update({ - 'template_multi_id': self.product_tmpl_id.id - }) + if 'product_multi_barcodes_ids' in vals: + self.product_multi_barcodes_ids.update({ + 'template_multi_id': self.product_tmpl_id.id + }) return res diff --git a/multi_barcodes_pos/models/product_template.py b/multi_barcodes_pos/models/product_template.py index c091263bc..64b92ac01 100755 --- a/multi_barcodes_pos/models/product_template.py +++ b/multi_barcodes_pos/models/product_template.py @@ -39,9 +39,10 @@ class ProductTemplate(models.Model): and update the associated multi-barcode product. """ res = super(ProductTemplate, self).create(vals) - res.template_multi_barcodes_ids.update({ - 'product_multi_id': res.product_variant_id.id - }) + if res.product_variant_count == 1: + res.template_multi_barcodes_ids.update({ + 'product_multi_id': res.product_variant_id.id + }) return res def write(self, vals): @@ -50,8 +51,9 @@ class ProductTemplate(models.Model): update the associated multi-barcode product. """ res = super(ProductTemplate, self).write(vals) - if self.template_multi_barcodes_ids: - self.template_multi_barcodes_ids.update({ - 'product_multi_id': self.product_variant_id.id - }) + for rec in self: + if rec.product_variant_count == 1 and rec.template_multi_barcodes_ids: + rec.template_multi_barcodes_ids.update({ + 'product_multi_id': rec.product_variant_id.id + }) return res