diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 944bf402..eb036294 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -13,7 +13,7 @@ from dateutil.relativedelta import relativedelta # import subprocess from odoo import api, fields, models, SUPERUSER_ID, _ from odoo.addons.sf_base.commons.common import Common -from odoo.exceptions import UserError +from odoo.exceptions import UserError,ValidationError from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController @@ -1019,13 +1019,15 @@ class ResMrpWorkOrder(models.Model): if workorder.state != 'done': is_production_id = False if record.routing_type == '解除装夹': - for workorder in record.production_id.workorder_ids: - if workorder.processing_panel == record.processing_panel: - rfid_code = workorder.rfid_code - workorder.write({'rfid_code_old': rfid_code, - 'rfid_code': False}) - workorder.rfid_code_old = rfid_code - workorder.rfid_code = False + for workorder in record.production_id.workorder_ids.filtered( + lambda a: a.processing_panel == record.processing_panel): + rfid_code = workorder.rfid_code + workorder.write({'rfid_code_old': rfid_code, + 'rfid_code': False}) + if workorder.rfid_code: + raise ValidationError(f'【{workorder.name}】工单解绑失败,请重新点击完成按钮!!!') + workorder.rfid_code_old = rfid_code + workorder.rfid_code = False if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']: logging.info('product_qty:%s' % record.production_id.product_qty) for move_raw_id in record.production_id.move_raw_ids: diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 2791c760..b7da1898 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -113,6 +113,7 @@ class ReSaleOrder(models.Model): 'price_unit': product.list_price, 'product_uom_qty': item['number'], 'model_glb_file': base64.b64decode(item['model_file']), + 'remark': item.get('remark') } return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals)