From 37977be8620916916169f2ec593f37072ecbad2a Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 16 Jul 2024 10:40:18 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=B7=A5=E5=8D=95=E8=A7=A3=E7=BB=91?= =?UTF-8?q?=E6=97=B6=E6=B7=BB=E5=8A=A0=E4=BA=8C=E6=AC=A1=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E8=A7=A3=E7=BB=91=E6=88=90=E5=8A=9F=EF=BC=9B?= =?UTF-8?q?2=E3=80=81=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E2=80=98=E5=A4=87=E6=B3=A8=E2=80=99=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 18 ++++++++++-------- sf_sale/models/sale_order.py | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) 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)