diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-05-22 15:34:03 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-05-22 15:34:03 +0700 |
| commit | 558130bbf48c33ddfa6080450c80bc8801a570f0 (patch) | |
| tree | 1824b9ee589f2b54657ab75f539b2f7d02224e7c /indoteknik_custom | |
| parent | 5ed0f18e6cdac093a8450de6d836ff179f9e1cf9 (diff) | |
form-merchant & quotation tampilan
Diffstat (limited to 'indoteknik_custom')
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 43 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 1 |
2 files changed, 43 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 0d4fc6c3..6ccb6fde 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -303,6 +303,12 @@ class SaleOrder(models.Model): ('approve', 'Approve') ], tracking=True, string='State Cancel', copy=False) + 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: @@ -1939,4 +1945,39 @@ class SaleOrder(models.Model): self._validate_delivery_amt() if any(field in vals for field in ["order_line", "client_order_ref"]): self._calculate_etrts_date() - return res
\ No newline at end of file + 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'
\ No newline at end of file diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index e0085eeb..5af3f4a2 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -102,6 +102,7 @@ <t t-esc="' to '" /> <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" /> <field name="percent_margin_after_delivery_purchase" /> |
