diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-18 11:56:33 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-18 11:56:33 +0700 |
| commit | 0aaf2d3af0e5096514f8b72850f6a3d2901cfc3e (patch) | |
| tree | 860c7069ea092ec5ae30aef08c3cd80fa573575b | |
| parent | 5aa6e8f5ed1bd628a5f4559a3f752b6e83ee2c49 (diff) | |
refactor product real stock
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 8 | ||||
| -rw-r--r-- | indoteknik_custom/models/product_sla.py | 9 |
2 files changed, 6 insertions, 11 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 8803bae3..8411ee25 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -18,11 +18,9 @@ class Product(controller.Controller): id = int(kw.get('id')) product = request.env['product.product'].search([('id', '=', id)], limit=1) product_sla = request.env['product.sla'].search([('product_variant_id', '=', id)], limit=1) + stock_vendor = request.env['stock.vendor'].search([('product_variant_id', '=', id)], limit=1) qty_available = product.qty_onhand_bandengan - qty_available -= 10 - if qty_available < 10: - qty_available = 0 qty = 0 sla_date = '-' @@ -33,8 +31,8 @@ class Product(controller.Controller): qty_altama = request.env['product.template'].get_stock_altama(product.default_code) qty_altama -= int(qty_altama * 0.1) qty_altama = math.ceil(float(qty_altama)) - qty = qty_altama - if qty_available > 10: + qty = qty_altama + if qty_available > 0: qty += qty_available sla_date = '1 Hari' elif qty_altama > 0: diff --git a/indoteknik_custom/models/product_sla.py b/indoteknik_custom/models/product_sla.py index f969502f..2e663d30 100644 --- a/indoteknik_custom/models/product_sla.py +++ b/indoteknik_custom/models/product_sla.py @@ -51,12 +51,9 @@ class ProductSla(models.Model): qty_available = 0 qty_available = product.qty_onhand_bandengan - qty_available -= 10 - if qty_available < 10: - qty_available = 0 - - if qty_available > 10: + + if qty_available > 0: self.sla = '1 Hari' query = [ @@ -80,7 +77,7 @@ class ProductSla(models.Model): rounded_leadtime = math.ceil(avg_leadtime) self.avg_leadtime = rounded_leadtime if rounded_leadtime >= 1 and rounded_leadtime <= 5: - self.sla = '3-6 Hari' + self.sla = '3-7 Hari' elif rounded_leadtime >= 6 and rounded_leadtime <= 10: self.sla = '4-12 Hari' elif rounded_leadtime >= 11: |
