summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order.py
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-08-10 11:32:18 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-08-10 11:32:18 +0700
commit4fd0d7f15ee2d7958c6d9c60faf03d1e9915eaef (patch)
treeb6ab45c654dfc9b4aa08b878b823b0010331d63f /indoteknik_custom/models/purchase_order.py
parent7b4f47e43d6485bb7822f1eb21497e68ab782ab1 (diff)
parent81c87b71d6cb7caad7230b9cca8545155d917214 (diff)
Merge branch 'production' of https://bitbucket.org/altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 7091bb72..d73f9037 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -187,13 +187,21 @@ class PurchaseOrder(models.Model):
def button_confirm(self):
res = super(PurchaseOrder, self).button_confirm()
+
if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.is_purchasing_manager and not self.env.user.is_leader:
raise UserError("Beda Margin dengan Sales, harus approval Manager")
if not self.sale_order_id and not self.env.user.is_purchasing_manager and not self.env.user.is_leader:
raise UserError("Tidak ada link dengan SO, harus approval Manager")
+ send_email = False
for line in self.order_line:
if not line.product_id.purchase_ok:
- raise UserError("Terdapat barang yang tidak bisa di proses")
+ raise UserError("Terdapat barang yang tidak bisa diproses")
+ if line.price_vendor != 0 and line.price_unit != line.price_vendor:
+ send_email = True
+ break
+
+ if send_email:
+ self._send_mail()
self.approval_status = 'approved'
self.po_status = 'menunggu'
@@ -206,6 +214,11 @@ class PurchaseOrder(models.Model):
self.date_planned = delta_time
return res
+
+ def _send_mail(self):
+ template_id = self.env.ref('indoteknik_custom.mail_template_po_sync_price').id
+ template = self.env['mail.template'].browse(template_id)
+ template.send_mail(self.id, force_send=True)
def po_approve(self):
if self.env.user.is_leader or self.env.user.is_purchasing_manager: