优化刀具物料扫码录入验证
This commit is contained in:
@@ -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]))
|
||||
|
||||
Reference in New Issue
Block a user