summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2025-01-07 17:02:06 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2025-01-07 17:02:06 +0700
commit7ac434ec0fcf75cb6eefe1892118b7c18b3db53a (patch)
tree2aaf7a6b409248acec3bcf58dbcb31999d4fef5f /indoteknik_custom/models
parent60f54931f8eac477ab737abab1710789e0a2aaf4 (diff)
sla
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/product_sla.py44
1 files changed, 18 insertions, 26 deletions
diff --git a/indoteknik_custom/models/product_sla.py b/indoteknik_custom/models/product_sla.py
index f597ec44..dfdf7662 100644
--- a/indoteknik_custom/models/product_sla.py
+++ b/indoteknik_custom/models/product_sla.py
@@ -12,8 +12,8 @@ class ProductSla(models.Model):
_rec_name = 'product_variant_id'
product_variant_id = fields.Many2one('product.product',string='Product')
- vendor_id = fields.Many2one('res.partner',string='Vendor', readonly=True)
- sla_vendor = fields.Char(string='SLA Vendor', readonly=True)
+ sla_vendor_id = fields.Many2one('vendor.sla',string='Vendor', readonly=True)
+ sla_vendor_duration = fields.Char(string='AVG Leadtime', related='sla_vendor_id.duration_unit')
avg_leadtime = fields.Char(string='AVG Leadtime', readonly=True)
leadtime = fields.Char(string='Leadtime', readonly=True)
sla = fields.Char(string='SLA', readonly=True)
@@ -52,7 +52,14 @@ class ProductSla(models.Model):
self.sla = '-'
product = self.product_variant_id
+
+ # qty_available = 0
+ # qty_available = product.qty_onhand_bandengan
+
+ # if qty_available > 0:
+ # self.sla = 1
+
q_vendor = [
('product_id', '=', product.id),
('is_winner', '=', True)
@@ -61,7 +68,6 @@ class ProductSla(models.Model):
vendor = self.env['purchase.pricelist'].search(q_vendor)
vendor_duration = 0
- print(vendor.vendor_id.id)
if vendor:
vendor_sla = self.env['vendor.sla'].search([('id_vendor', '=', vendor.vendor_id.id)], limit=1)
sla_vendor = int(vendor_sla.duration) if vendor_sla else 0
@@ -69,17 +75,9 @@ class ProductSla(models.Model):
if vendor_sla.unit == 'hari':
vendor_duration = vendor_sla.duration * 24 * 60
else :
- vendor_duration = vendor_sla.duration
-
- self.sla_vendor = vendor_sla.duration_unit
- self.vendor_id = vendor.vendor_id.id
-
- qty_available = 0
- qty_available = product.qty_onhand_bandengan
-
-
- if qty_available > 0:
- self.sla = '1 Hari'
+ vendor_duration = vendor_sla.duration * 60
+
+ self.sla_vendor_id = vendor_sla.id if vendor_sla else False
query = [
('product_id', '=', product.id),
@@ -88,12 +86,13 @@ class ProductSla(models.Model):
('picking_id.state', 'not in', ['cancel'])
]
picking = self.env['stock.move.line'].search(query)
+
leadtimes=[]
for stock in picking:
date_delivered = stock.picking_id.driver_departure_date
- date_so_confirmed = stock.picking_id.sale_id.date_order
- if date_delivered and date_so_confirmed:
- leadtime = date_delivered - date_so_confirmed
+ date_do_ready = stock.picking_id.date_reserved
+ if date_delivered and date_do_ready:
+ leadtime = date_delivered - date_do_ready
leadtime_in_days = leadtime.days
leadtimes.append(leadtime_in_days)
@@ -102,12 +101,5 @@ class ProductSla(models.Model):
rounded_leadtime = math.ceil(avg_leadtime)
estimation_sla = (rounded_leadtime * 24 * 60) + vendor_duration
estimation_sla_days = estimation_sla / (24 * 60)
- self.sla = estimation_sla_days
- self.avg_leadtime = int(rounded_leadtime)
- # self.sla = (sla_vendor + self.avg_leadtime) / 2
- # if rounded_leadtime >= 1 and rounded_leadtime <= 5:
- # self.sla = '3-7 Hari'
- # elif rounded_leadtime >= 6 and rounded_leadtime <= 10:
- # self.sla = '4-12 Hari'
- # elif rounded_leadtime >= 11:
- # self.sla = 'Indent' \ No newline at end of file
+ self.sla = math.ceil(estimation_sla_days)
+ self.avg_leadtime = int(rounded_leadtime) \ No newline at end of file