优化刀具物料扫码录入验证
This commit is contained in:
@@ -36,16 +36,19 @@ class StockLot(models.Model):
|
|||||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||||
# 调用父类的name_search方法
|
# 调用父类的name_search方法
|
||||||
records = super(StockLot, self).name_search(name=name, args=args, operator=operator, limit=limit)
|
records = super(StockLot, self).name_search(name=name, args=args, operator=operator, limit=limit)
|
||||||
|
|
||||||
if records:
|
if records:
|
||||||
return records
|
return records
|
||||||
else:
|
else:
|
||||||
# 在调用父类方法之后执行自定义逻辑
|
# 在调用父类方法之后执行自定义逻辑
|
||||||
|
self.tool_verify(args, name)
|
||||||
|
return records
|
||||||
|
|
||||||
|
def tool_verify(self, args, name):
|
||||||
|
# 刀具物料验证
|
||||||
if 5 >= len(args) > 3:
|
if 5 >= len(args) > 3:
|
||||||
if args[2][2] in ['整体式刀具', '刀片', '刀杆', '刀盘', '刀柄', '夹头']:
|
|
||||||
objs = self.search([('name', '=', name), ('quant_ids.location_id.name', 'in', ['刀具房']),
|
objs = self.search([('name', '=', name), ('quant_ids.location_id.name', 'in', ['刀具房']),
|
||||||
('quant_ids.quantity', '>', 0)])
|
('quant_ids.quantity', '>', 0)])
|
||||||
|
if args[2][2] in ['整体式刀具', '刀片', '刀杆', '刀盘', '刀柄', '夹头']:
|
||||||
if objs.product_id.categ_id.name == '刀具':
|
if objs.product_id.categ_id.name == '刀具':
|
||||||
raise ValidationError('这是【%s】物料,请扫入正确的【%s】物料!!!' % (
|
raise ValidationError('这是【%s】物料,请扫入正确的【%s】物料!!!' % (
|
||||||
objs.product_id.cutting_tool_material_id.name, args[2][2]))
|
objs.product_id.cutting_tool_material_id.name, args[2][2]))
|
||||||
return records
|
|
||||||
|
|||||||
Reference in New Issue
Block a user