diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-08-09 06:48:17 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-08-09 06:48:17 +0000 |
| commit | 072694ec9464142ff1029ea4b070496e513c03c6 (patch) | |
| tree | aa04c3b421ac936a65a7706e9372d6d901f932db /indoteknik_custom/models | |
| parent | 4aa5108543075227378b856ce31f478bd5a3b3db (diff) | |
| parent | 3ef9d136bd238464de7ff0a224b1a68a9b7bb1f3 (diff) | |
Merged in email-po (pull request #91)
Email po
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 15 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 15 |
2 files changed, 29 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: diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index f255095f..39aeba0f 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -28,6 +28,21 @@ class PurchaseOrderLine(models.Model): qty_outgoing = fields.Float('Qty Outgoing', compute='compute_qty_stock') qty_available_store = fields.Float(string='Available') suggest = fields.Char(string='Suggest') + price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') + + def compute_price_vendor(self): + for line in self: + purchase_pricelist = self.env['purchase.pricelist'].search([ + ('product_id', '=', line.product_id.id), + ('vendor_id', '=', line.order_id.partner_id.id) + ], limit=1) + + 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: |
