summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-13 17:26:30 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-13 17:26:30 +0700
commit1c9308c1a18bd89612dc7fca5726cbf96c28deed (patch)
treeacc36cfa86d66b4e230aa5cf6830e2c6724d77a9 /indoteknik_custom/models/sale_order.py
parent9f994de3f13f6be24d17233bf6890e6e88dd959b (diff)
parent46e968a3b28c00aa74e6f09b451d5a87e8523043 (diff)
Merge branch 'odoo-production' into iman/pengajuan-tempo
# Conflicts: # indoteknik_custom/security/ir.model.access.csv
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 2b448874..2ef1f43d 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