From 3285da702db176851e78db9d8afe7af866c31b94 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Sat, 29 Apr 2023 10:37:22 +0700 Subject: add po id in procurement monitoring --- .../models/procurement_monitoring_detail.py | 16 +++++++++++++++- .../views/procurement_monitoring_detail.xml | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/procurement_monitoring_detail.py b/indoteknik_custom/models/procurement_monitoring_detail.py index 97d35faf..e9da8147 100644 --- a/indoteknik_custom/models/procurement_monitoring_detail.py +++ b/indoteknik_custom/models/procurement_monitoring_detail.py @@ -21,6 +21,20 @@ class SaleMonitoringDetail(models.Model): qty_po = fields.Integer(string='Qty PO') date_order = fields.Datetime(string="Date Order") status = fields.Char(string="Status") + po_ids = fields.Many2many('purchase.order', string='PO', compute='_compute_po') + + def _compute_po(self): + for line in self: + query = [ + ('order_id.sale_order_id', '=', line.sale_order_id.id), + ('order_id.approval_status', '=', 'approved'), + ('product_id', '=', line.product_id.id), + ] + pos = self.env['purchase.order.line'].search(query) + po_ids = [] + for po in pos: + po_ids.append(po.order_id.id) + line.po_ids = po_ids def init(self): tools.drop_view_if_exists(self.env.cr, self._table) @@ -53,6 +67,6 @@ class SaleMonitoringDetail(models.Model): AND so.create_date >= '2022-08-10' and so.so_status not in ('terproses') ) a - where a.qty_po < a.qty_so + --where a.qty_po < a.qty_so ) """ % self._table) diff --git a/indoteknik_custom/views/procurement_monitoring_detail.xml b/indoteknik_custom/views/procurement_monitoring_detail.xml index b3785d14..8f3827c1 100644 --- a/indoteknik_custom/views/procurement_monitoring_detail.xml +++ b/indoteknik_custom/views/procurement_monitoring_detail.xml @@ -14,6 +14,7 @@ +