From 5691ea8569ab70a801ff5fc06adfe717a67224a3 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 20 Aug 2025 11:09:27 +0700 Subject: Block Manual Input from keyboard --- indoteknik_custom/models/stock_picking.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index cb36eb2f..3d04a416 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -2070,6 +2070,8 @@ class CheckProduct(models.Model): _name = 'check.product' _description = 'Check Product' _order = 'picking_id, id' + _inherit = ['barcodes.barcode_events_mixin'] # ⬅️ aktifkan barcode handler + picking_id = fields.Many2one( 'stock.picking', @@ -2084,6 +2086,21 @@ class CheckProduct(models.Model): status = fields.Char(string='Status', compute='_compute_status') code_product = fields.Char(string='Code Product') + def write(self, vals): + if 'code_product' in vals and not self.env.context.get('from_barcode_scan'): + raise UserError("Field Code Product hanya bisa diisi melalui barcode scan.") + res = super().write(vals) + # konsolidasi dll milik Anda tetap jalan + if not self.env.context.get('skip_consolidate'): + self.with_context(skip_consolidate=True)._consolidate_duplicate_lines() + return res + + # Scanner handler + def on_barcode_scanned(self, barcode): + self.ensure_one() + self.with_context(from_barcode_scan=True).write({'code_product': barcode}) + self._onchange_code_product() + @api.onchange('code_product') def _onchange_code_product(self): if not self.code_product: -- cgit v1.2.3