From 30eb623bace6b5ba9a1e275c7bdf70fc5920a583 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 8 Aug 2023 15:29:29 +0700 Subject: sync price unit po & price purchase pricelist --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/purchase_order.py | 9 +++ indoteknik_custom/models/purchase_order_line.py | 6 +- indoteknik_custom/views/mail_template_po.xml | 84 +++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 indoteknik_custom/views/mail_template_po.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index b7aadbdf..252d92b4 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -87,6 +87,7 @@ 'views/account_move_multi_update.xml', 'views/airway_bill.xml', 'views/product_attribute_value.xml', + 'views/mail_template_po.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 7091bb72..38e617e7 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -206,8 +206,17 @@ 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): + 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 1b5bba3a..450d3430 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -30,15 +30,15 @@ class PurchaseOrderLine(models.Model): 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.partner_id.id) + ('vendor_id', '=', line.order_id.partner_id.id) ], limit=1) - price_vendor = purchase_pricelist.product_price + price_vendor = format(purchase_pricelist.product_price, ".2f") + price_vendor = float(price_vendor) line.price_vendor = price_vendor def compute_qty_stock(self): diff --git a/indoteknik_custom/views/mail_template_po.xml b/indoteknik_custom/views/mail_template_po.xml new file mode 100644 index 00000000..8eb72e12 --- /dev/null +++ b/indoteknik_custom/views/mail_template_po.xml @@ -0,0 +1,84 @@ + + + + + PO: Sync Unit Price Purchase Pricelist + + Your PO ${object.name} + + azkan4elll@gmail.com + + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+ PO
+ + ${object.name} + +
+
+
+
+ + + + + + + +
+
+ Dear Stefanus Darren, +

+ Terdapat PO yang harga Unit Price nya tidak sama dengan yang ada di purchase pricelist nya. +

+ Berikut adalah rincian PO: + % for line in object.order_line: +
    +
  • Nama Produk: ${line.product_id.name}
  • +
  • Harga Unit dalam PO: ${line.price_unit}
  • +
  • Harga Unit dalam Purchase Pricelist: ${line.price_vendor}
  • +
+ % endfor + Silahkan periksa dan lakukan koreksi jika diperlukan. +

+ Terima kasih. +
+
+
+
+
+
+
+ +
+
+
\ No newline at end of file -- cgit v1.2.3