summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-10-03 10:12:24 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-10-03 10:12:24 +0700
commit4a69c71eab2d4ea3504a0cf6e3a9ca241be48594 (patch)
treeeb03e833a86acfe72870099d1671ad6dfae86d37 /indoteknik_custom/models/sale_order.py
parent8b63d79efe0137ce6af535847f33868e73ce8d3c (diff)
push
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
-rwxr-xr-xindoteknik_custom/models/sale_order.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index f8127d8c..538e0209 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -145,9 +145,8 @@ class SaleOrder(models.Model):
missing_weight_products.append(line.product_id.name)
if missing_weight_products:
- product_names = '\n'.join(missing_weight_products)
- self.message_post(body=f"Produk berikut tidak memiliki berat: \n{product_names}")
-
+ product_names = '<br/>'.join(missing_weight_products)
+ self.message_post(body=f"Produk berikut tidak memiliki berat:<br/>{product_names}")
if total_weight == 0:
raise UserError("Tidak dapat mengestimasi ongkir tanpa berat yang valid.")
@@ -802,9 +801,36 @@ class SaleOrder(models.Model):
'body_html': email_body,
'email_to': salesperson_email,
}).send()
+
+ def validate_different_vendor(self):
+ different_vendor = self.order_line.filtered(lambda l: 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',
+ })
+ for line in self.line:
+ self.env['vendor.approval.line'].create({
+ 'vendor_approval_id': vendor_approval.id,
+ 'product_id': line.product_id.id,
+ 'product_uom_qty': line.product_uom_qty,
+ 'vendor_id': line.vendor_id.id,
+ 'vendor_md_id': line.vendor_md_id.id,
+ 'purchase_price': line.purchase_price,
+ 'purchase_price_md': line.purchase_price_md,
+ })
+
+ return True
+ else:
+ return False
+
+
def action_confirm(self):
for order in self:
+ if order.validate_partner_invoice_due():
+ return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor')
+
order.check_data_real_delivery_address()
order.sale_order_check_approve()
order._validate_order()