diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-12-30 16:30:20 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-12-30 16:30:20 +0700 |
| commit | 60f54931f8eac477ab737abab1710789e0a2aaf4 (patch) | |
| tree | 3af779e54116bc79bc6c513adeda267899a22a3e | |
| parent | 3ba967de0aa6c70b0d070a7ca723d49008aa0dd2 (diff) | |
vendor sla
| -rw-r--r-- | indoteknik_custom/models/product_sla.py | 30 | ||||
| -rw-r--r-- | indoteknik_custom/views/vendor_sla.xml | 2 |
2 files changed, 23 insertions, 9 deletions
diff --git a/indoteknik_custom/models/product_sla.py b/indoteknik_custom/models/product_sla.py index 05210cdc..f597ec44 100644 --- a/indoteknik_custom/models/product_sla.py +++ b/indoteknik_custom/models/product_sla.py @@ -25,6 +25,7 @@ class ProductSla(models.Model): def generate_product_variant_id_sla(self, limit=5000): # Filter produk non-Altama + products = self.env['product.product'].search([ ('x_manufacture', 'not in', [10, 122, 89]), ('location_id', '=', 57), @@ -58,10 +59,19 @@ 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) - self.sla_vendor = "{} {}".format(vendor_sla.duration, vendor_sla.unit) + sla_vendor = int(vendor_sla.duration) if vendor_sla else 0 + if sla_vendor > 0: + 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 @@ -90,10 +100,14 @@ class ProductSla(models.Model): if len(leadtimes) > 0: avg_leadtime = sum(leadtimes) / len(leadtimes) rounded_leadtime = math.ceil(avg_leadtime) - self.avg_leadtime = rounded_leadtime - 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 + 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 diff --git a/indoteknik_custom/views/vendor_sla.xml b/indoteknik_custom/views/vendor_sla.xml index d0e7f3e6..cf4425eb 100644 --- a/indoteknik_custom/views/vendor_sla.xml +++ b/indoteknik_custom/views/vendor_sla.xml @@ -26,7 +26,7 @@ <group> <field name="id_vendor" string="Vendor Name" /> <field name="duration" string="SLA Duration" /> - <field name="unit" string="SLA Unit" /> + <field name="unit" string="SLA Time" /> </group> </sheet> </form> |
