diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-28 10:43:27 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-28 10:43:27 +0700 |
| commit | ec21c4721f35028fc9b2a61bd0dbc6e4bf600e74 (patch) | |
| tree | 0fe30eb7285f93bededb83a3dd6529738af088c7 | |
| parent | e13be084e77a1b1beda14062df2f98d45789a6ee (diff) | |
<Miqdad> fix state retur ccm stuck at waiting for operation
| -rw-r--r-- | indoteknik_custom/models/tukar_guling.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index c683f75a..cb630a04 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -538,6 +538,11 @@ class TukarGuling(models.Model): self.state = 'approval_sales' def update_doc_state(self): + bu_pick = self.env['stock.picking'].search([ + ('origin', '=', self.operations.origin), + ('name', 'ilike', 'BU/PICK'), + ]) + # OUT tukar guling if self.operations.picking_type_id.id == 29 and self.return_type == 'tukar_guling': total_out = self.env['stock.picking'].search_count([ @@ -552,7 +557,26 @@ class TukarGuling(models.Model): if self.state == 'approved' and total_out > 0 and done_out == total_out: self.state = 'done' - # OUT revisi SO + #SO Lama (gk ada bu pick) + elif self.operations.picking_type_id.id == 29 and self.return_type == 'retur_so' and not bu_pick: + # so_lama = self.env['sale.order'].search([ + # ('name', '=', self.operations.origin), + # ('state', '=', 'done'), + # ('group_id.name', '=', self.operations.origin) + # ]) + total_ort = self.env['stock.picking'].search_count([ + ('tukar_guling_id', '=', self.id), + ('picking_type_id', '=', 74), + ]) + done_srt = self.env['stock.picking'].search([ + ('tukar_guling_id', '=', self.id), + ('picking_type_id', '=', 73), + ('state', '=', 'done') + ]) + if self.state == 'approved' and total_ort == 0 and done_srt and not bu_pick: + self.state = 'done' + + # OUT retur SO elif self.operations.picking_type_id.id == 29 and self.return_type == 'retur_so': total_ort = self.env['stock.picking'].search_count([ ('tukar_guling_id', '=', self.id), |
