From 4faeda11b839b27a3745e1111eebb4566eea83ce Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 8 Apr 2024 14:43:46 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E6=89=AB=E6=89=98=E7=9B=98Rfid=E7=BB=91=E5=AE=9ARfid=E7=A0=81?= =?UTF-8?q?=E5=BD=95=E5=85=A5=E4=BF=A1=E6=81=AF=E6=97=B6=EF=BC=8C=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E5=BC=80=E5=A7=8B=E7=AD=89=E6=8C=89=E9=94=AE?= =?UTF-8?q?=E6=B6=88=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 14af7aab..3b6e8ead 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -826,23 +826,30 @@ class SfWorkOrderBarcodes(models.Model): # raise UserError('该托盘已绑定工件,请先解除绑定!!!') if workorder: if workorder.routing_type == '装夹预调': + if workorder.state in ['progress', 'done']: + work_state = {'progress': '进行中', 'done': '已完工'} + raise UserError('该工单%s,不能重新绑定托盘' % work_state.get(workorder.state)) lots = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)]) if lots: for lot in lots: if lot.product_id.categ_type == '夹具': - workorder.write({ + val = { 'tray_serial_number': lot.name, 'tray_product_id': lot.product_id.id, 'tray_brand_id': lot.product_id.brand_id.id, 'tray_type_id': lot.product_id.fixture_material_id.id, - 'tray_model_id': lot.product_id.fixture_model_id.id - }) + 'tray_model_id': lot.product_id.fixture_model_id.id, + 'rfid_code': barcode + } + workorder.write(val) + self.write(val) workorder_rfid = self.env['mrp.workorder'].search( [('production_id', '=', workorder.production_id.id)]) if workorder_rfid: for item in workorder_rfid: item.write({'rfid_code': barcode}) - workorder.env.cr.commit() + else: + raise UserError('该托盘信息不存在!!!') # stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)]) # if stock_move_line.product_id.categ_type == '夹具': # workorder.write({