From 5d29ddf74f982a686b6dfec2381162a0c5ed4c7c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 18 Nov 2022 17:25:56 +0700 Subject: add qty available in po line --- indoteknik_custom/models/purchase_order_line.py | 9 +++++++++ indoteknik_custom/views/purchase_order.xml | 3 +++ 2 files changed, 12 insertions(+) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 60e4c8b0..621373f4 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -22,6 +22,15 @@ class PurchaseOrderLine(models.Model): help="Total % Margin in Sales Order Header") delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line') line_no = fields.Integer('No', default=0) + qty_available = fields.Float('Qty Available', compute='compute_qty_available') + + def compute_qty_available(self): + for line in self: + line.qty_available = line.product_id.virtual_available + + @api.onchange('product_id') + def _onchange_product_custom(self): + self.compute_qty_available() # Override method from addons/purchase/models/purchase.py @api.onchange('product_qty', 'product_uom') diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 128f2413..f1a13615 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -43,6 +43,9 @@ + + + -- cgit v1.2.3