summaryrefslogtreecommitdiff
path: root/indoteknik_custom
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2025-03-17 09:03:51 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2025-03-17 09:03:51 +0700
commite4d86ee7cb2fac5c09876b1aeefda04f27ebedd0 (patch)
tree024f708d2f1a8635f78ab36892848f74d468e1c9 /indoteknik_custom
parent2b1783368e7be632e18be524b5288713125e7902 (diff)
biteship handle sla SO
Diffstat (limited to 'indoteknik_custom')
-rwxr-xr-xindoteknik_custom/models/sale_order.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index b22ee2ee..7ccc551b 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -450,10 +450,11 @@ class SaleOrder(models.Model):
@api.depends('date_order', 'estimated_arrival_days', 'state', 'estimated_arrival_days_start')
def _compute_eta_date(self):
+ current_date = datetime.now().date()
for rec in self:
if rec.date_order and rec.state not in ['cancel'] and rec.estimated_arrival_days and rec.estimated_arrival_days_start:
- rec.eta_date = rec.date_order + timedelta(days=rec.estimated_arrival_days)
- rec.eta_date_start = rec.date_order + timedelta(days=rec.estimated_arrival_days_start)
+ rec.eta_date = current_date + timedelta(days=rec.estimated_arrival_days)
+ rec.eta_date_start = current_date + timedelta(days=rec.estimated_arrival_days_start)
else:
rec.eta_date = False
rec.eta_date_start = False
@@ -527,22 +528,23 @@ class SaleOrder(models.Model):
@api.depends("order_line.product_id")
def _compute_etrts_date(self): #Function to calculate Estimated Ready To Ship Date
- for rec in self:
- max_slatime = 1 # Default SLA jika tidak ada
- slatime = self.calculate_sla_by_vendor(rec.order_line)
- max_slatime = max(max_slatime, slatime['slatime'])
-
-
- current_date = datetime.now().date()
-
- if rec.date_order:
- sum_days = max_slatime + self.get_days_until_next_business_day(current_date) - 1
- rec.estimated_arrival_days = sum_days
+ if self.order_line:
+ for rec in self:
+ max_slatime = 1 # Default SLA jika tidak ada
+ slatime = self.calculate_sla_by_vendor(rec.order_line)
+ max_slatime = max(max_slatime, slatime['slatime'])
- eta_date = current_date + timedelta(days=sum_days)
- rec.estimated_ready_ship_date = eta_date
- rec.commitment_date = eta_date
- rec.expected_ready_to_ship = eta_date
+ current_date = datetime.now().date()
+
+ if rec.date_order:
+ sum_days = max_slatime + self.get_days_until_next_business_day(current_date) - 1
+ if rec.source_id.name != 'Website':
+ rec.estimated_arrival_days = sum_days
+
+ eta_date = current_date + timedelta(days=sum_days)
+ rec.estimated_ready_ship_date = eta_date
+ rec.commitment_date = eta_date
+ rec.expected_ready_to_ship = eta_date