From 11ec586c67da3a290fd699d8f752f871be97f651 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 6 Jul 2023 09:03:01 +0700 Subject: refactor qty available product sla --- indoteknik_custom/models/product_sla.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/product_sla.py b/indoteknik_custom/models/product_sla.py index c09c5018..f969502f 100644 --- a/indoteknik_custom/models/product_sla.py +++ b/indoteknik_custom/models/product_sla.py @@ -47,17 +47,20 @@ class ProductSla(models.Model): self.avg_leadtime = '-' self.sla = '-' + product = self.product_variant_id + qty_available = 0 - for stock in self.product_variant_id.stock_quant_ids: - if stock.location_id.id == 57: - qty_available += stock.quantity + qty_available = product.qty_onhand_bandengan qty_available -= 10 + + if qty_available < 10: + qty_available = 0 if qty_available > 10: self.sla = '1 Hari' query = [ - ('product_id', '=', self.product_variant_id.id), + ('product_id', '=', product.id), ('picking_id', '!=', False), ('picking_id.location_id', '=', 57), ('picking_id.state', 'not in', ['cancel']) @@ -81,4 +84,4 @@ class ProductSla(models.Model): elif rounded_leadtime >= 6 and rounded_leadtime <= 10: self.sla = '4-12 Hari' elif rounded_leadtime >= 11: - self.sla = 'Indent' + self.sla = 'Indent' \ No newline at end of file -- cgit v1.2.3