diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-06-02 01:09:39 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-06-02 01:09:39 +0700 |
| commit | fe458043667bb7f1cde757659fefe0174252002d (patch) | |
| tree | ccabce1e4178cf2fcb96c09ac2a964e81f551735 | |
| parent | 2f89da69c9ec8d78f187be5afd254cdd594ee24a (diff) | |
<hafid> estimasi barang sampai fix>
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index f1280b37..aa1b4b49 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1057,16 +1057,23 @@ class SaleOrder(models.Model): rec.compute_fullfillment = True - @api.depends('date_order', 'estimated_arrival_days', 'state', 'estimated_arrival_days_start') + @api.depends('expected_ready_to_ship', 'shipping_option_id.etd', 'state') def _compute_eta_date(self): - 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) - rec.eta_date_start = current_date + timedelta(days=rec.estimated_arrival_days_start) + for rec in self: + if rec.expected_ready_to_ship and rec.shipping_option_id and rec.shipping_option_id.etd and rec.state not in ['cancel']: + etd_text = rec.shipping_option_id.etd + match = re.match(r"(\d+)\s*-\s*(\d+)", etd_text) + if match: + start_days = int(match.group(1)) + end_days = int(match.group(2)) + rec.eta_date_start = rec.expected_ready_to_ship + timedelta(days=start_days) + rec.eta_date = rec.expected_ready_to_ship + timedelta(days=end_days) + else: + rec.eta_date_start = False + rec.eta_date = False else: - rec.eta_date = False rec.eta_date_start = False + rec.eta_date = False def get_days_until_next_business_day(self, start_date=None, *args, **kwargs): |
