diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-06 09:03:01 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-06 09:03:01 +0700 |
| commit | 11ec586c67da3a290fd699d8f752f871be97f651 (patch) | |
| tree | 1c2df5a3380a7b7b3e40189ede46c70c614c6e6b | |
| parent | 1ac873d214e2f93c63102e16e868944947156b6e (diff) | |
refactor qty available product sla
| -rw-r--r-- | indoteknik_custom/models/product_sla.py | 13 |
1 files 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 |
