diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-09 10:32:32 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-09 10:32:32 +0700 |
| commit | 3ef9d136bd238464de7ff0a224b1a68a9b7bb1f3 (patch) | |
| tree | 4a26ad5ec0ad6700b061e0ebfb189e89d5b2cf95 | |
| parent | 30eb623bace6b5ba9a1e275c7bdf70fc5920a583 (diff) | |
add new condition email po
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 14 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 9 | ||||
| -rw-r--r-- | indoteknik_custom/views/mail_template_po.xml | 16 |
3 files changed, 24 insertions, 15 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 38e617e7..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' @@ -213,10 +221,6 @@ class PurchaseOrder(models.Model): template.send_mail(self.id, force_send=True) def po_approve(self): - for line in self.order_line: - if line.price_unit != line.price_vendor: - self._send_mail() - if self.env.user.is_leader or self.env.user.is_purchasing_manager: raise UserError("Bisa langsung Confirm") elif self.total_percent_margin == self.total_so_percent_margin and self.sale_order_id: diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 450d3430..39aeba0f 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -37,9 +37,12 @@ class PurchaseOrderLine(models.Model): ('vendor_id', '=', line.order_id.partner_id.id) ], limit=1) - price_vendor = format(purchase_pricelist.product_price, ".2f") - price_vendor = float(price_vendor) - line.price_vendor = price_vendor + if purchase_pricelist: + price_vendor = format(purchase_pricelist.product_price, ".2f") + price_vendor = float(price_vendor) + line.price_vendor = price_vendor + else: + line.price_vendor = 0 def compute_qty_stock(self): for line in self: diff --git a/indoteknik_custom/views/mail_template_po.xml b/indoteknik_custom/views/mail_template_po.xml index 8eb72e12..77c21837 100644 --- a/indoteknik_custom/views/mail_template_po.xml +++ b/indoteknik_custom/views/mail_template_po.xml @@ -6,11 +6,11 @@ <field name="model_id" ref="model_purchase_order" /> <field name="subject">Your PO ${object.name}</field> <field name="email_from"></field> - <field name="email_to">azkan4elll@gmail.com</field> + <field name="email_to">darren@indoteknik.co.id</field> <field name="body_html" type="html"> <table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;"> - <tr> + <tr> <td align="center"> <table border="0" cellpadding="0" cellspacing="0" width="590" style="padding: 16px; background-color: white; color: #454748; border-collapse:separate;"> @@ -51,11 +51,13 @@ <br/><br/> Berikut adalah rincian PO: % for line in object.order_line: - <ul> - <li>Nama Produk: ${line.product_id.name}</li> - <li>Harga Unit dalam PO: ${line.price_unit}</li> - <li>Harga Unit dalam Purchase Pricelist: ${line.price_vendor}</li> - </ul> + % if line.price_vendor != 0 and line.price_unit != line.price_vendor + <ul> + <li>Nama Produk: ${line.product_id.name}</li> + <li>Harga Unit dalam PO: ${line.price_unit}</li> + <li>Harga Unit dalam Purchase Pricelist: ${line.price_vendor}</li> + </ul> + % endif % endfor Silahkan periksa dan lakukan koreksi jika diperlukan. <br/><br/> |
