summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-05-14 11:24:04 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-05-14 11:24:04 +0700
commitc5506e8e7c22b02968d4a8ae56b7147ee85e686a (patch)
tree07fa6cbe14fe4fcb9901c2479ee7914dc4738960
parentdceb69d104510bff6930ad0fe373dcf198417503 (diff)
fix bug
-rw-r--r--indoteknik_custom/models/barcoding_product.py4
-rwxr-xr-xindoteknik_custom/models/product_template.py9
2 files changed, 5 insertions, 8 deletions
diff --git a/indoteknik_custom/models/barcoding_product.py b/indoteknik_custom/models/barcoding_product.py
index 5f4e80ea..335b481a 100644
--- a/indoteknik_custom/models/barcoding_product.py
+++ b/indoteknik_custom/models/barcoding_product.py
@@ -41,10 +41,8 @@ class BarcodingProduct(models.Model):
@api.onchange('product_id', 'quantity')
def _onchange_product_or_quantity(self):
if self.product_id and self.quantity > 0:
- # Clear existing lines
self.barcoding_product_line = [(5, 0, 0)]
- # Add a new line with the current product and quantity
lines = []
for i in range(int(self.quantity)):
lines.append((0, 0, {
@@ -55,14 +53,12 @@ class BarcodingProduct(models.Model):
self.barcoding_product_line = lines
def write(self, vals):
- """Override write to update sequence_with_total when quantity changes"""
res = super().write(vals)
if 'quantity' in vals and self.type == 'multiparts':
self._update_sequence_with_total()
return res
def _update_sequence_with_total(self):
- """Update sequence_with_total for all lines"""
for rec in self:
total = int(rec.quantity)
for index, line in enumerate(rec.barcoding_product_line, start=1):
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 2679fbfd..03c7ced4 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -1320,10 +1320,11 @@ class ProductProduct(models.Model):
# simpan data lama dan log perubahan field
def write(self, vals):
- old_values = self._collect_old_values(vals)
- result = super().write(vals)
- self._log_field_changes_product_variants(vals, old_values)
- return result
+ if self.default_code in vals:
+ old_values = self._collect_old_values(vals)
+ result = super().write(vals)
+ self._log_field_changes_product_variants(vals, old_values)
+ return result
class OutstandingMove(models.Model):
_name = 'v.move.outstanding'