From 0d95dabc04a3f5334168e989705e9a7568130df4 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Tue, 24 Jun 2025 08:41:47 +0700 Subject: spesific tf --- indoteknik_custom/models/tukar_guling.py | 8 +++++++- indoteknik_custom/views/tukar_guling.xml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index dfa62dc8..d75dad41 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -25,6 +25,7 @@ class TukarGuling(models.Model): date = fields.Datetime('Date', default=fields.Datetime.now, required=True) operations = fields.Many2one('stock.picking', 'Operations', domain=[('picking_type_id.code', '=', 'outgoing')], help='Nomor BU/Out atau BU/Pick') + spesific_operations = fields.Many2one('stock.picking', 'Spesific Operations', domain = [('origin', '=', origin), ('state', '=', 'done')]) ba_num = fields.Text('Nomor BA') notes = fields.Text('Notes') return_type = fields.Selection(String='Return Type', selection=[ @@ -44,6 +45,10 @@ class TukarGuling(models.Model): @api.onchange('operations') def _onchange_operations(self): """Auto-populate lines ketika operations dipilih""" + if self.origin: + return {'domain': { + 'specific_transfers': [('origin', '=', self.origin), ('state', '=', 'done')] + }} if self.operations: from_return_picking = self.env.context.get('from_return_picking', False) or \ self.env.context.get('default_line_ids', False) @@ -294,7 +299,6 @@ class TukarGuling(models.Model): operation_picking = record.operations - # 1. Cari semua picking DONE berdasarkan origin SO related_pickings = self.env['stock.picking'].search([ ('origin', '=', record.origin), ('state', '=', 'done'), @@ -391,6 +395,8 @@ class TukarGuling(models.Model): 'quantity': line.product_uom_qty, 'move_id': move.id, })) + if not move: + raise UserError("eror woi") if not return_lines: return None diff --git a/indoteknik_custom/views/tukar_guling.xml b/indoteknik_custom/views/tukar_guling.xml index 942f085d..7bc783eb 100644 --- a/indoteknik_custom/views/tukar_guling.xml +++ b/indoteknik_custom/views/tukar_guling.xml @@ -12,7 +12,7 @@ -- cgit v1.2.3