summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-08 12:27:38 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-08 12:27:38 +0700
commitdfeb874b7b9d938b8c8863645d9b21830d1628dc (patch)
treef7c1b195347c02a532bc8e342aa640e74b62737c /indoteknik_custom/models/sale_order.py
parent02d27a0e871dd4949c9382000843cd35dd3db3f8 (diff)
<iman> update code so reset to draft
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
-rwxr-xr-xindoteknik_custom/models/sale_order.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index f5e7e8a1..7b2d9bf8 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -1031,8 +1031,9 @@ class SaleOrder(models.Model):
if self.have_outstanding_invoice:
raise UserError("Invoice harus di Cancel dahulu")
- elif self.have_outstanding_picking:
- raise UserError("DO harus di Cancel dahulu")
+ for line in self.order_line:
+ if line.qty_delivered > 0:
+ raise UserError("DO harus di-cancel terlebih dahulu.")
if not self.web_approval:
self.web_approval = 'company'
@@ -1410,4 +1411,16 @@ class SaleOrder(models.Model):
'npwp': partner.npwp,
'email': partner.email,
'customer_type': partner.customer_type,
- }) \ No newline at end of file
+ })
+
+ def write(self, vals):
+ for order in self:
+ if order.state in ['sale', 'cancel']:
+ if 'order_line' in vals:
+ new_lines = vals.get('order_line', [])
+ for command in new_lines:
+ if command[0] == 0: # A new line is being added
+ raise UserError(
+ "SO tidak dapat ditambahkan produk baru karena SO sudah menjadi sale order.")
+ res = super(SaleOrder, self).write(vals)
+ return res \ No newline at end of file