diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-06-19 02:44:25 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-06-19 02:44:25 +0000 |
| commit | 347dde6c03a623e36796ebc03b6b18aa00b93b9d (patch) | |
| tree | ff05f189e95e04823d67bfa29b901bf27d9913d6 | |
| parent | 393228f1b25d3fa460d8300c45642e66edbca88a (diff) | |
| parent | c4640e2f846d853412c5f1cb0901e50208fa0216 (diff) | |
Merged in et_product (pull request #338)
Et product
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 41 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 15 |
2 files changed, 53 insertions, 3 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index ee9d6f70..6da46398 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -349,6 +349,47 @@ class SaleOrder(models.Model): date_unhold = fields.Datetime(string='Date Unhold', tracking=True, readonly=True, help='Waktu ketika SO di Unhold' ) + et_products = fields.Datetime(string='ET Products', compute='_compute_et_products', help="Leadtime produk berdasarkan SLA vendor, tanpa logistik.") + + eta_date_reserved = fields.Datetime( + string="Date Reserved", + compute="_compute_eta_date_reserved", + help="Tanggal pertama kali barang berhasil di-reservasi pada DO (BU/PICK/) yang berstatus Siap Dikirim." + ) + + @api.depends('order_line.product_id', 'date_order') + def _compute_et_products(self): + jakarta = pytz.timezone("Asia/Jakarta") + for order in self: + if not order.order_line or not order.date_order: + order.et_products = False + continue + + # Ambil tanggal order sebagai basis + base_date = order.date_order + if base_date.tzinfo is None: + base_date = jakarta.localize(base_date) + else: + base_date = base_date.astimezone(jakarta) + + # Ambil nilai SLA vendor dalam hari + sla_data = order.calculate_sla_by_vendor(order.order_line) + sla_days = sla_data.get('slatime', 1) + + # Hitung ETA produk (tanpa logistik) + eta_datetime = base_date + timedelta(days=sla_days) + + # Simpan ke field sebagai UTC-naive datetime (standar Odoo) + order.et_products = eta_datetime.astimezone(pytz.utc).replace(tzinfo=None) + + @api.depends('picking_ids.state', 'picking_ids.date_reserved') + def _compute_eta_date_reserved(self): + for order in self: + pickings = order.picking_ids.filtered( + lambda p: p.state == 'assigned' and p.date_reserved and 'BU/PICK/' in (p.name or '') + ) + order.eta_date_reserved = min(pickings.mapped('date_reserved')) if pickings else False + @api.onchange('shipping_cost_covered') def _onchange_shipping_cost_covered(self): if self.shipping_cost_covered == 'indoteknik' and self.select_shipping_option == 'biteship': diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index d0442677..2a159307 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -103,10 +103,10 @@ <field name="compute_fullfillment" invisible="1" /> </field> <field name="tag_ids" position="after"> - <field name="eta_date_start"/> + <!-- <field name="eta_date_start"/> --> <t t-esc="' to '"/> - <field name="eta_date" readonly="1"/> - <field name="expected_ready_to_ship"/> + <!-- <field name="eta_date" readonly="1"/> --> + <!-- <field name="expected_ready_to_ship"/> --> <field name="ready_to_ship_status_detail"/> <field name="flash_sale"/> <field name="margin_after_delivery_purchase"/> @@ -144,6 +144,15 @@ <field name="date_doc_kirim" readonly="1"/> <field name="notification" readonly="1"/> </field> + <xpath expr="//page[@name='other_information']/group/group[@name='sale_reporting']" position="after"> + <group string="ETA"> + <field name="et_products"/> + <field name="eta_date_reserved"/> + <field name="expected_ready_to_ship"/> + <field name="eta_date_start"/> + <field name="eta_date" readonly="1"/> + </group> + </xpath> <xpath expr="//form/sheet/notebook/page/field[@name='order_line']" position="attributes"> <attribute name="attrs"> |
