From b88e4af4e2c228837605501ac6ee18acd85b1761 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 5 Feb 2024 14:09:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=80=E5=85=B7=E7=89=A9?= =?UTF-8?q?=E6=96=99=E6=89=AB=E7=A0=81=E5=BD=95=E5=85=A5=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/maintenance_equipment.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py index e43cb767..f38f3a6c 100644 --- a/sf_tool_management/models/maintenance_equipment.py +++ b/sf_tool_management/models/maintenance_equipment.py @@ -36,16 +36,19 @@ class StockLot(models.Model): def name_search(self, name='', args=None, operator='ilike', limit=100): # 调用父类的name_search方法 records = super(StockLot, self).name_search(name=name, args=args, operator=operator, limit=limit) - if records: return records else: # 在调用父类方法之后执行自定义逻辑 - if 5 >= len(args) > 3: - if args[2][2] in ['整体式刀具', '刀片', '刀杆', '刀盘', '刀柄', '夹头']: - objs = self.search([('name', '=', name), ('quant_ids.location_id.name', 'in', ['刀具房']), - ('quant_ids.quantity', '>', 0)]) - if objs.product_id.categ_id.name == '刀具': - raise ValidationError('这是【%s】物料,请扫入正确的【%s】物料!!!' % ( - objs.product_id.cutting_tool_material_id.name, args[2][2])) + self.tool_verify(args, name) return records + + def tool_verify(self, args, name): + # 刀具物料验证 + if 5 >= len(args) > 3: + objs = self.search([('name', '=', name), ('quant_ids.location_id.name', 'in', ['刀具房']), + ('quant_ids.quantity', '>', 0)]) + if args[2][2] in ['整体式刀具', '刀片', '刀杆', '刀盘', '刀柄', '夹头']: + if objs.product_id.categ_id.name == '刀具': + raise ValidationError('这是【%s】物料,请扫入正确的【%s】物料!!!' % ( + objs.product_id.cutting_tool_material_id.name, args[2][2]))