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):
"""

View File

@@ -247,3 +247,9 @@ class ProductProduct(models.Model):
m = int(stock_lot_id.name[-3:]) + 1
num = "%03d" % m
return '%s-%s' % (code, num)
class SfShelfLocationLot(models.Model):
_inherit = 'sf.shelf.location.lot'

View File

@@ -524,6 +524,7 @@
<div>
<separator string="刀柄:" style="font-size: 13px;"/>
</div>
<group>
<field name="handle_code_id" string="序列号" placeholder="请选择"
options="{'no_create': True, 'no_quick_create': True}"
@@ -534,6 +535,10 @@
<field name="handle_specification_id" string="规格"/>
<field name="sf_tool_brand_id_5" string="品牌"/>
</group>
<div>
<button string="更多" name="set_tool_lot" type="object"
class="btn-primary" context="{'tool_type': '刀柄'}"/>
</div>
</group>
<group col="1"
attrs="{'invisible': [('bar_lot_id', '=', False),'|','|',('integral_lot_id', '!=', False),('pad_lot_id', '!=', False),('assemble_status', 'not in', ['0','01'])]}">
@@ -552,6 +557,10 @@
<field name="bar_specification_id" string="规格"/>
<field name="sf_tool_brand_id_3" string="品牌"/>
</group>
<div>
<button string="更多" name="set_tool_lot" type="object"
class="btn-primary" context="{'tool_type': '刀杆'}"/>
</div>
</group>
<group col="1"
attrs="{'invisible': [('pad_lot_id', '=', False),'|','|',('integral_lot_id', '!=', False),('bar_lot_id', '!=', False),('assemble_status', 'not in', ['0','01'])]}">
@@ -572,6 +581,10 @@
<field name="sf_tool_brand_id_4" string="品牌"/>
</group>
</group>
<div>
<button string="更多" name="set_tool_lot" type="object"
class="btn-primary" context="{'tool_type': '刀盘'}"/>
</div>
</group>
</group>
<group col="1">
@@ -592,6 +605,10 @@
<field name="integral_specification_id" string="规格"/>
<field name="sf_tool_brand_id_1" string="品牌"/>
</group>
<div>
<button string="更多" name="set_tool_lot" type="object"
class="btn-primary" context="{'tool_type': '整体式刀具'}"/>
</div>
</group>
<group col="1"
attrs="{'invisible': [('blade_lot_id', '=', False),'|', ('integral_lot_id', '!=', False),('assemble_status', 'not in', ['0','01'])]}">
@@ -610,6 +627,10 @@
<field name="blade_specification_id" string="规格"/>
<field name="sf_tool_brand_id_2" string="品牌"/>
</group>
<div>
<button string="更多" name="set_tool_lot" type="object"
class="btn-primary" context="{'tool_type': '刀片'}"/>
</div>
</group>
</group>
<!-- <group col="1"-->