summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-07-03 13:50:12 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-07-03 13:50:12 +0700
commit917bc54da1bdcbbac36e20aa483e8fd0bac39e4f (patch)
tree6925842e16310751c662295f32079ee147cabb02
parente8a6caab3ec347114ab7e18ccae5855e30d81ce2 (diff)
product sla non altama
-rw-r--r--indoteknik_custom/models/product_sla.py34
-rw-r--r--indoteknik_custom/views/product_sla.xml1
2 files changed, 21 insertions, 14 deletions
diff --git a/indoteknik_custom/models/product_sla.py b/indoteknik_custom/models/product_sla.py
index 8d314dd9..4f74b28f 100644
--- a/indoteknik_custom/models/product_sla.py
+++ b/indoteknik_custom/models/product_sla.py
@@ -18,9 +18,13 @@ class ProductSla(models.Model):
# Filter produk non-Altama
products = self.env['product.product'].search([
('x_manufacture', 'not in', [10,122,89]),
- ])
+ ('location_id', '=', 57),
+ ], offset=74465)
+ i = 1
for product in products:
+ print(f"PRODUCT KE: {i}/{len(products)}")
+ i += 1
sla = self.env['product.sla'].create({
'product_variant_id': product.id,
})
@@ -34,6 +38,7 @@ class ProductSla(models.Model):
('product_id', '=', sla.product_variant_id.id),
('picking_id', '!=', False),
('picking_id.state', '=', 'done'),
+ ('picking_id.location_id', '=', 57)
]
picking = self.env['stock.move.line'].search(query)
leadtimes=[]
@@ -50,16 +55,19 @@ class ProductSla(models.Model):
avg_leadtime = sum(leadtimes)/len(leadtimes)
rounded_leadtime = math.ceil(float(avg_leadtime))
sla.avg_leadtime = rounded_leadtime
- if picking.picking_id.location_id == 57 and picking.picking_id.qty_available > 10:
+ if sla.product_variant_id.qty_available > 10:
+ sla.sla = '1 Hari'
+ elif sla.avg_leadtime and float(sla.avg_leadtime) >= 1 and float(sla.avg_leadtime) <= 5:
+ sla.sla = '3-6 Hari'
+ elif sla.avg_leadtime and float(sla.avg_leadtime) >= 6 and float(sla.avg_leadtime) <= 10:
+ sla.sla = '4-12 Hari'
+ elif sla.avg_leadtime and float(sla.avg_leadtime) >= 11:
+ sla.sla = 'Indent'
+ else:
+ sla.sla = '-'
+
+ for stock in sla.product_variant_id.stock_quant_ids:
+ if not sla.avg_leadtime and stock.location_id.id == 57 and stock.quantity > 0:
sla.sla = '1 Hari'
- elif sla.avg_leadtime and float(sla.avg_leadtime) >= 1 and float(sla.avg_leadtime) <= 5:
- sla.sla = '3-6 Hari'
- elif sla.avg_leadtime and float(sla.avg_leadtime) >= 6 and float(sla.avg_leadtime) <= 10:
- sla.sla = '4-12 Hari'
- elif sla.avg_leadtime and float(sla.avg_leadtime) >= 11:
- sla.sla = 'Indent'
- else:
- sla.sla = '-'
- elif not sla.product_variant_id.stock_move_ids.picking_id and sla.product_variant_id.stock_quant_ids.location_id.id == 57 and sla.product_variant_id.stock_quant_ids.quantity > 0:
- sla.sla = '1 Hari'
- sla.avg_leadtime = '-'
+ sla.avg_leadtime = '-'
+
diff --git a/indoteknik_custom/views/product_sla.xml b/indoteknik_custom/views/product_sla.xml
index 378a977b..2cc29d7c 100644
--- a/indoteknik_custom/views/product_sla.xml
+++ b/indoteknik_custom/views/product_sla.xml
@@ -27,7 +27,6 @@
<sheet string="Product Sla">
<group>
<group>
- <field name="number"/>
<field name="product_variant_id"/>
<field name="avg_leadtime"/>
<field name="sla"/>