summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-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