summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-10-03 11:55:16 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-10-03 11:55:16 +0700
commit7059f095dd09649f7c12f74ff29200f644bbc854 (patch)
tree9e7dc3c1e0ca800a1b589cb3c65dddf5ad798894 /indoteknik_custom/models/sale_order.py
parent4a69c71eab2d4ea3504a0cf6e3a9ca241be48594 (diff)
push
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
-rwxr-xr-xindoteknik_custom/models/sale_order.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 538e0209..a6ea6c81 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -78,6 +78,7 @@ class SaleOrder(models.Model):
payment_link_midtrans = fields.Char(string='Payment Link', help='Url payment yg digenerate oleh midtrans, harap diserahkan ke customer agar dapat dilakukan pembayaran secara mandiri')
payment_qr_code = fields.Binary("Payment QR Code")
due_id = fields.Many2one('due.extension', string="Due Extension", readonly=True, tracking=True)
+ vendor_approval_id = fields.Many2one('vendor.approval', string="Vendor Approval", readonly=True, tracking=True)
customer_type = fields.Selection([
('pkp', 'PKP'),
('nonpkp', 'Non PKP')
@@ -104,6 +105,7 @@ class SaleOrder(models.Model):
('cust_procurement', 'Customer Procurement')
], string='Web Approval', copy=False)
compute_fullfillment = fields.Boolean(string='Compute Fullfillment', compute="_compute_fullfillment")
+ vendor_approval = fields.Boolean(string='Vendor Approval')
note_ekspedisi = fields.Char(string="Note Ekspedisi")
date_kirim_ril = fields.Datetime(string='Tanggal Kirim SJ', compute='_compute_date_kirim', copy=False)
date_status_done = fields.Datetime(string='Date Done DO', compute='_compute_date_kirim', copy=False)
@@ -703,6 +705,8 @@ class SaleOrder(models.Model):
self._validate_order()
for order in self:
order.order_line.validate_line()
+ if order.validate_different_vendor() and not self.vendor_approval:
+ return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor')
partner = order.partner_id.parent_id or order.partner_id
if not partner.property_payment_term_id:
@@ -803,12 +807,14 @@ class SaleOrder(models.Model):
}).send()
def validate_different_vendor(self):
- different_vendor = self.order_line.filtered(lambda l: l.vendor_id.id != l.vendor_md_id.id)
+ different_vendor = self.order_line.filtered(lambda l: l.vendor_id and l.vendor_md_id and l.vendor_id.id != l.vendor_md_id.id)
if different_vendor:
vendor_approval = self.env['vendor.approval'].create({
'order_id': self.id,
'state': 'draft',
})
+
+ self.vendor_approval_id = vendor_approval.id
for line in self.line:
self.env['vendor.approval.line'].create({
'vendor_approval_id': vendor_approval.id,
@@ -823,12 +829,10 @@ class SaleOrder(models.Model):
return True
else:
return False
-
-
def action_confirm(self):
for order in self:
- if order.validate_partner_invoice_due():
+ if order.validate_different_vendor() and not self.vendor_approval:
return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor')
order.check_data_real_delivery_address()