From c29187f2e1be3bed90ab8f4eece5bbc087861522 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 11 Apr 2023 18:47:48 +0700 Subject: add suggestion while sync so to po --- indoteknik_custom/models/purchase_order.py | 6 ++++++ indoteknik_custom/models/purchase_order_line.py | 2 ++ indoteknik_custom/views/purchase_order.xml | 6 ++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 0ef6a9f2..8809d048 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -139,11 +139,17 @@ class PurchaseOrder(models.Model): self.order_line.unlink() for order_line in self.sale_order_id.order_line: if order_line.product_id.id and order_line.product_id.id not in products_exception: + qty_available = order_line.product_id.virtual_available + suggest = 'harus beli' + if order_line.product_id.virtual_available > order_line.product_qty: + suggest = 'masih cukup' values = { 'order_id': self.id, 'product_id': order_line.product_id.id, 'name': order_line.product_id.display_name, 'product_qty': order_line.product_qty, + 'qty_available_store': qty_available, + 'suggest': suggest, } self.env['purchase.order.line'].sudo().create(values) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 8439df5d..f255095f 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -26,6 +26,8 @@ class PurchaseOrderLine(models.Model): qty_onhand = fields.Float('Qty On Hand', compute='compute_qty_stock') qty_incoming = fields.Float('Qty Incoming', compute='compute_qty_stock') qty_outgoing = fields.Float('Qty Outgoing', compute='compute_qty_stock') + qty_available_store = fields.Float(string='Available') + suggest = fields.Char(string='Suggest') def compute_qty_stock(self): for line in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index fb85f4c1..eb5267e0 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -46,10 +46,8 @@ - - - - + + -- cgit v1.2.3