summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/stock_picking.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/stock_picking.py')
-rw-r--r--indoteknik_custom/models/stock_picking.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 6967e1a3..f766dc3f 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -1,7 +1,7 @@
from odoo import fields, models, api, _
from odoo.exceptions import AccessError, UserError, ValidationError
from odoo.tools.float_utils import float_is_zero
-from datetime import timedelta, datetime
+from datetime import timedelta, datetime as waktu
from itertools import groupby
import pytz, requests, json, requests
from dateutil import parser
@@ -169,6 +169,33 @@ class StockPicking(models.Model):
biteship_id = fields.Char(string="Biteship Respon ID")
biteship_tracking_id = fields.Char(string="Biteship Trackcking ID")
biteship_waybill_id = fields.Char(string="Biteship Waybill ID")
+ estimated_ready_ship_date = fields.Datetime(string='ET Ready to Ship', copy=False, store=True, related='sale_id.estimated_ready_ship_date')
+ countdown_hours = fields.Float(string='Countdown in Hours', compute='_compute_countdown_hours', store=True, default=False)
+ countdown_ready_to_ship = fields.Char(string='Countdown Ready to Ship', compute='_compute_countdown_ready_to_ship')
+
+ @api.depends('estimated_ready_ship_date', 'state')
+ def _compute_countdown_hours(self):
+ for record in self:
+ if record.state in ('cancel', 'done') or not record.estimated_ready_ship_date:
+ # Gunakan nilai yang sangat besar sebagai placeholder
+ record.countdown_hours = 999999
+ else:
+ delta = record.estimated_ready_ship_date - waktu.now()
+ record.countdown_hours = delta.total_seconds() / 3600
+
+ @api.depends('estimated_ready_ship_date', 'state')
+ def _compute_countdown_ready_to_ship(self):
+ for record in self:
+ if record.state in ('cancel', 'done'):
+ record.countdown_ready_to_ship = False
+ else:
+ if record.estimated_ready_ship_date:
+ delta = record.estimated_ready_ship_date - waktu.now()
+ days = delta.days
+ hours, remainder = divmod(delta.seconds, 3600)
+ record.countdown_ready_to_ship = f"{days} days, {hours} hours"
+ else:
+ record.countdown_ready_to_ship = False
def _compute_lalamove_image_html(self):
for record in self: