From 955f0eff6fb1917c3cf0fde8ee6994ee43148732 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 18 Dec 2023 14:06:16 +0700 Subject: change field suggest po --- indoteknik_custom/models/purchase_order.py | 4 ++++ indoteknik_custom/models/purchase_order_line.py | 5 ++--- indoteknik_custom/views/purchase_order.xml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 177a4744..285c5a95 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -214,6 +214,7 @@ class PurchaseOrder(models.Model): # suggest = 'harus beli' # if qty_available > order_line.product_qty: # suggest = 'masih cukup' + values = { 'order_id': self.id, 'product_id': order_line.product_id.id, @@ -224,6 +225,9 @@ class PurchaseOrder(models.Model): 'so_line_id': order_line.id, } self.order_line.create(values) + for order_line in self.order_line: + order_line.suggest_purchasing() + def compute_count_line_product(self): for order in self: diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 5e1c7b5f..f1c20106 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -27,15 +27,14 @@ class PurchaseOrderLine(models.Model): 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', compute='_compute_suggest_purchasing') + suggest = fields.Char(string='Suggest') price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') so_line_id = fields.Many2one('sale.order.line', string='ID SO Line') indent = fields.Boolean(string='Indent', help='centang ini jika barang indent') is_ltc = fields.Boolean(string='Sudah di LTC', default=False, help='centang ini jika barang sudah di LTC') note = fields.Char(string='Note') - def _compute_suggest_purchasing(self): - print(1) + def suggest_purchasing(self): for line in self: if line.qty_available < 0: line.suggest = 'harus beli' diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 4cf83dd4..8e74df4a 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -55,7 +55,7 @@ - + -- cgit v1.2.3