summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order.py
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2025-04-24 13:54:06 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2025-04-24 13:54:06 +0700
commitd9d8b9f3afc0ad60ca1199b08ab6e2836663a0de (patch)
treeac67e346cb6c1eb867a905f7cf2fb72e444df46d /indoteknik_custom/models/sale_order.py
parenta76389076431e63519835656eebdba4e4d0eda3a (diff)
fixing revisi renca
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
-rwxr-xr-xindoteknik_custom/models/sale_order.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index c83ffd61..a7ee9db8 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -496,7 +496,7 @@ 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()
+ current_date = datetime.now()
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 = current_date + timedelta(days=rec.estimated_arrival_days)
@@ -507,7 +507,19 @@ class SaleOrder(models.Model):
def get_days_until_next_business_day(self,start_date=None, *args, **kwargs):
- today = start_date or datetime.today().date()
+ now = start_date or datetime.now()
+
+ # Jika hanya diberikan tanggal (tanpa jam), asumsikan jam 00:00
+ if isinstance(now, datetime):
+ order_datetime = now
+ else:
+ order_datetime = datetime.combine(now, datetime.min.time())
+
+ today = order_datetime.date()
+
+ if order_datetime.time() > datetime.strptime("15:00", "%H:%M").time():
+ today += timedelta(days=1)
+
offset = 0 # Counter jumlah hari yang ditambahkan
holiday = self.env['hr.public.holiday']
@@ -568,13 +580,13 @@ class SaleOrder(models.Model):
rec.expected_ready_to_ship = False
return
- current_date = datetime.now().date()
+ current_date = datetime.now()
max_slatime = 1 # Default SLA jika tidak ada
slatime = self.calculate_sla_by_vendor(rec.order_line)
max_slatime = max(max_slatime, slatime['slatime'])
- sum_days = max_slatime + self.get_days_until_next_business_day(current_date) - 1
+ sum_days = max_slatime + self.get_days_until_next_business_day(current_date)
if not rec.estimated_arrival_days:
rec.estimated_arrival_days = sum_days
@@ -597,7 +609,7 @@ class SaleOrder(models.Model):
max_slatime = 1 # Default SLA jika tidak ada
slatime = self.calculate_sla_by_vendor(rec.order_line)
max_slatime = max(max_slatime, slatime['slatime'])
- sum_days = max_slatime + self.get_days_until_next_business_day(current_date) - 1
+ sum_days = max_slatime + self.get_days_until_next_business_day(current_date)
eta_minimum = current_date + timedelta(days=sum_days)
if expected_date < eta_minimum: