summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-10-13 10:09:47 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-10-13 10:09:47 +0700
commit3acb428bfa048acb6d4d2d57e9d8720e77d08075 (patch)
tree73e4f4f20d9b781c0479b26579689587d79639af
parent1e91160f83aaad30b424439a50065f20b84927f7 (diff)
add credit limit and payment term validation
-rwxr-xr-xindoteknik_custom/models/sale_order.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 05e3e19f..a23a6d44 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -44,6 +44,10 @@ class SaleOrder(models.Model):
for order in self:
if order.state == 'cancel' or order.state == 'done' or order.state == 'sale':
raise UserError("Status harus draft atau sent")
+ if not order.partner_id.property_payment_term_id:
+ raise UserError("Payment Term pada Master Data Customer harus diisi")
+ if not order.partner_id.active_limit:
+ raise UserError("Credit Limit pada Master Data Customer harus diisi")
if not order.sales_tax_id:
raise UserError("Tax di Header harus diisi")
if not order.carrier_id:
@@ -56,16 +60,6 @@ class SaleOrder(models.Model):
raise UserError(_('Tidak bisa Confirm menggunakan Produk Sementara'))
if not line.vendor_id or not line.purchase_price:
raise UserError(_('Isi Vendor dan Harga Beli sebelum Request Approval'))
- # if line.item_percent_margin <= 15 and not self.env.user.is_leader: # akbar or tyas
- # approval2 += 1
- # elif line.item_percent_margin <= 25 and not self.env.user.is_leader and not self.env.user.is_sales_manager:
- # approval1 += 1
- # if approval2 > 0:
- # order.approval_status = 'pengajuan2'
- # elif approval1 > 0:
- # order.approval_status = 'pengajuan1'
- # else:
- # raise UserError("Bisa langsung Confirm")
if order.total_percent_margin <= 15 and not self.env.user.is_leader:
order.approval_status = 'pengajuan2'
elif order.total_percent_margin <= 25 and not self.env.user.is_leader and not self.env.user.is_sales_manager: