1、新增夹具物料搜索模型,完成tree视图和form视图;2、新增夹具物料序列号、夹具物料搜索模型注册到cloud的接口,优化刀具物料序列号注册接口及流程;3、删除刀具物料搜索模型的无关字段;
This commit is contained in:
@@ -97,6 +97,7 @@ class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
|
||||
tool_material_search_id = fields.Many2one('sf.tool.material.search', string='刀具物料搜索')
|
||||
fixture_material_search_id = fields.Many2one('sf.fixture.material.search', string='夹具物料搜索')
|
||||
tool_material_status = fields.Selection(
|
||||
[('未入库', '未入库'), ('可用', '可用'), ('在用', '在用'), ('报废', '报废')], string='状态',
|
||||
compute='_compute_tool_material_status', store=True)
|
||||
@@ -105,20 +106,20 @@ class StockLot(models.Model):
|
||||
def _compute_tool_material_status(self):
|
||||
for record in self:
|
||||
if record:
|
||||
if record.quant_ids:
|
||||
if record.quant_ids[-1].location_id.name == '刀具房':
|
||||
record.tool_material_status = '可用'
|
||||
elif record.quant_ids[-1].location_id.name == '刀具组装位置':
|
||||
record.tool_material_status = '在用'
|
||||
else:
|
||||
record.tool_material_status = '未入库'
|
||||
|
||||
@api.onchange('tool_material_status')
|
||||
def _onchange_tool_material_status(self):
|
||||
for obj in self:
|
||||
if obj:
|
||||
# 注册刀具物料状态到cloud平台
|
||||
obj.enroll_tool_material_stock()
|
||||
if record.product_id.categ_id.name in ['刀具', '夹具']:
|
||||
if record.quant_ids:
|
||||
if record.quant_ids[-1].location_id.name in ['刀具房', '夹具房']:
|
||||
record.tool_material_status = '可用'
|
||||
elif record.quant_ids[-1].location_id.name == '刀具组装位置':
|
||||
record.tool_material_status = '在用'
|
||||
else:
|
||||
record.tool_material_status = '未入库'
|
||||
if record.tool_material_search_id:
|
||||
# 注册刀具物料状态到cloud平台
|
||||
record.enroll_tool_material_stock()
|
||||
elif record.fixture_material_search_id:
|
||||
# 注册夹具物料状态到cloud平台
|
||||
record.enroll_fixture_material_stock()
|
||||
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||
@@ -149,7 +150,14 @@ class StockLot(models.Model):
|
||||
tool_material_search = self.env['sf.tool.material.search'].sudo().search(
|
||||
[('id', '=', record.product_id.tool_material_id)])
|
||||
if tool_material_search:
|
||||
record.tool_material_search_id = tool_material_search
|
||||
record.tool_material_status = '未入库'
|
||||
record.tool_material_search_id = tool_material_search.id
|
||||
elif record.product_id.categ_id.name == '夹具':
|
||||
fixture_material_search = self.env['sf.fixture.material.search'].sudo().search(
|
||||
[('id', '=', record.product_id.fixture_material_search_id)])
|
||||
if fixture_material_search:
|
||||
record.tool_material_status = '未入库'
|
||||
record.fixture_material_search_id = fixture_material_search.id
|
||||
return records
|
||||
|
||||
|
||||
@@ -157,6 +165,7 @@ class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
tool_material_id = fields.Char('刀具物料搜索模型ID')
|
||||
fixture_material_search_id = fields.Char('夹具物料搜索模型ID')
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
@@ -167,4 +176,9 @@ class ProductProduct(models.Model):
|
||||
'product_id': record.id
|
||||
})
|
||||
record.tool_material_id = tool_material.id
|
||||
elif record.categ_id.name == '夹具':
|
||||
fixture_material = self.env['sf.fixture.material.search'].sudo().create({
|
||||
'product_id': record.id
|
||||
})
|
||||
record.fixture_material_search_id = fixture_material.id
|
||||
return records
|
||||
|
||||
Reference in New Issue
Block a user