diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-05-23 09:22:27 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-05-23 09:22:27 +0700 |
| commit | f6f59e660af6c4229ada54f7313d68867df1ba15 (patch) | |
| tree | 9a27b4e0e6571c639ba173df5ae25a2e7014aefd /indoteknik_custom/models/sale_order.py | |
| parent | 68378dd2fb8d61b282a672ca0f09033d15d82283 (diff) | |
| parent | 558130bbf48c33ddfa6080450c80bc8801a570f0 (diff) | |
Merge branch 'CR/form-merchant' into odoo-backup
# Conflicts:
# indoteknik_custom/models/sale_order.py
# indoteknik_custom/views/sale_order.xml
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index bdf8f1eb..6028a1d0 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -336,6 +336,12 @@ class SaleOrder(models.Model): date_unhold = fields.Datetime(string='Date Unhold', tracking=True, readonly=True, help='Waktu ketika SO di Unhold' ) + ready_to_ship_status_detail = fields.Char( + string='Status Shipping Detail', + compute='_compute_ready_to_ship_status_detail' + ) + + def _compute_total_margin_excl_third_party(self): for order in self: if order.amount_untaxed == 0: @@ -2006,5 +2012,45 @@ class SaleOrder(models.Model): if any(fields in vals for fields in ['delivery_amt', 'carrier_id', 'shipping_cost_covered']): self._validate_delivery_amt() if any(field in vals for field in ["order_line", "client_order_ref"]): +<<<<<<< HEAD self._calculate_etrts_date() return res +======= + self._calculate_etrts_date() + return res + + # @api.depends('commitment_date') + def _compute_ready_to_ship_status_detail(self): + for order in self: + eta = order.commitment_date + + match_lines = self.env['purchase.order.sales.match'].search([ + ('sale_id', '=', order.id) + ]) + + if match_lines: + for match in match_lines: + po = match.purchase_order_id + product = match.product_id + + po_line = self.env['purchase.order.line'].search([ + ('order_id', '=', po.id), + ('product_id', '=', product.id) + ], limit=1) + + stock_move = self.env['stock.move'].search([ + ('purchase_line_id', '=', po_line.id) + ], limit=1) + picking_in = stock_move.picking_id + + result_date = picking_in.date_done if picking_in else None + if result_date: + status = "Early" if result_date < eta else "Delay" + result_date_str = result_date.strftime('%m/%d/%Y') + eta_str = eta.strftime('%m/%d/%Y') + order.ready_to_ship_status_detail = f"Expected: {eta_str} | Realtime: {result_date_str} | {status}" + else: + order.ready_to_ship_status_detail = "On Track" + else: + order.ready_to_ship_status_detail = 'On Track' +>>>>>>> CR/form-merchant |
