优化功能刀具组装的刀具物料验证
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from odoo import models, api, fields
|
from odoo import models, api, fields
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class SfMaintenanceEquipmentTool(models.Model):
|
class SfMaintenanceEquipmentTool(models.Model):
|
||||||
@@ -26,3 +27,25 @@ class SfMaintenanceEquipmentTool(models.Model):
|
|||||||
'cutter_spacing_code_id': tool.id
|
'cutter_spacing_code_id': tool.id
|
||||||
})
|
})
|
||||||
return tools
|
return tools
|
||||||
|
|
||||||
|
|
||||||
|
class StockLot(models.Model):
|
||||||
|
_inherit = 'stock.lot'
|
||||||
|
|
||||||
|
@api.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]))
|
||||||
|
return records
|
||||||
|
|||||||
Reference in New Issue
Block a user