1、组装单新增五种物料的【更多】按钮,点击按钮跳转至新的弹窗界面,根据功能刀具清单BOM的配置,搜索出全部满足条件的刀柄产品或者其他刀具物料对应的批次、货位,使用tree视图提供选择。2、新增产品tree、search视图

This commit is contained in:
yuxianghui
2024-09-11 17:49:43 +08:00
parent e2d741937e
commit da5e322229
3 changed files with 74 additions and 1 deletions

View File

@@ -925,7 +925,53 @@ class FunctionalToolAssembly(models.Model):
else:
raise ValidationError(f'功能刀具清单BOM的组装方式错误{options}')
# def set_
def set_tool_lot(self):
# 获取BOM的刀具物料产品信息
tool_data = self._get_inventory_bom(self.tool_inventory_id)
# 获取刀具类型
tool_type = self.env.context.get('tool_type')
if tool_type == '刀柄':
tool_material_ids = tool_data.get('handle_ids')
elif tool_type == '整体式刀具':
tool_material_ids = self._get_all_material_location_lot(tool_data.get('integral_ids'))
elif tool_type == '刀片':
tool_material_ids = self._get_all_material_location_lot(tool_data.get('handle_ids'))
elif tool_type == '刀杆':
tool_material_ids = self._get_all_material_location_lot(tool_data.get('bar_ids'))
else:
tool_material_ids = self._get_all_material_location_lot(tool_data.get('pad_ids'))
if tool_type == '刀柄':
return {
"type": "ir.actions.act_window",
"res_model": "product.product",
"views": [[self.env.ref('sf_tool_management.view_tool_product_tree').id, "tree"],
[self.env.ref('sf_tool_management.view_tool_product_search').id, "search"]],
"target": "new",
"domain": [('id', 'in', tool_material_ids.ids)]
}
elif tool_type in ['整体式刀具', '刀片', '刀杆', '刀盘']:
return {
"type": "ir.actions.act_window",
"res_model": "sf.shelf.location.lot",
"views": [[False, "tree"]],
"target": "new",
"domain": [('id', 'in', tool_material_ids.ids)],
"context": {'create': False}
}
def _get_all_material_location_lot(self, material_ids):
""" 获取所有满足条件 """
location_id = self.env['stock.location'].search([('name', '=', '刀具房')])
stock_quant_ids = self.env['stock.quant'].sudo().search(
[('location_id', '=', location_id.id), ('product_id', 'in', material_ids.ids), ('quantity', '>', '0')])
lot_ids = []
for stock_quant_id in stock_quant_ids:
lot_ids.append(stock_quant_id.lot_id.id)
location_lots = self.env['sf.shelf.location.lot'].sudo().search([('lot_id', 'in', lot_ids)])
return location_lots
def functional_tool_assembly(self):
"""