1、实现功能刀具点击开始组装时,自动获取功能刀具清单BOM信息,并根据规则匹配刀具物料信息进行信息初始化;2、对组装单form界面进行调整,并隐藏夹头物料的所以信息;
This commit is contained in:
@@ -493,11 +493,13 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.integral_freight_lot_id = False
|
||||
|
||||
@api.depends('integral_freight_lot_id')
|
||||
@api.depends('integral_freight_lot_id', 'integral_freight_barcode_id')
|
||||
def _compute_integral_lot_id(self):
|
||||
for item in self:
|
||||
if item.integral_freight_lot_id:
|
||||
item.integral_lot_id = item.integral_freight_lot_id.lot_id.id
|
||||
elif not item.integral_freight_barcode_id:
|
||||
item.integral_lot_id = False
|
||||
|
||||
@api.depends('integral_lot_id')
|
||||
def _compute_integral_product_id(self):
|
||||
@@ -527,11 +529,13 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.blade_freight_lot_id = False
|
||||
|
||||
@api.depends('blade_freight_lot_id')
|
||||
@api.depends('blade_freight_lot_id', 'blade_freight_barcode_id')
|
||||
def _compute_blade_lot_id(self):
|
||||
for item in self:
|
||||
if item.blade_freight_lot_id:
|
||||
item.blade_lot_id = item.blade_freight_lot_id.lot_id.id
|
||||
elif not item.blade_freight_barcode_id:
|
||||
item.blade_lot_id = False
|
||||
|
||||
@api.depends('blade_lot_id')
|
||||
def _compute_blade_product_id(self):
|
||||
@@ -561,11 +565,13 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.bar_freight_lot_id = False
|
||||
|
||||
@api.depends('bar_freight_lot_id')
|
||||
@api.depends('bar_freight_lot_id', 'bar_freight_barcode_id')
|
||||
def _compute_bar_lot_id(self):
|
||||
for item in self:
|
||||
if item.bar_freight_lot_id:
|
||||
item.bar_lot_id = item.bar_freight_lot_id.lot_id.id
|
||||
elif not item.bar_freight_barcode_id:
|
||||
item.bar_lot_id = False
|
||||
|
||||
@api.depends('bar_lot_id')
|
||||
def _compute_bar_product_id(self):
|
||||
@@ -595,11 +601,13 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.pad_freight_lot_id = False
|
||||
|
||||
@api.depends('pad_freight_lot_id')
|
||||
@api.depends('pad_freight_lot_id', 'pad_freight_barcode_id')
|
||||
def _compute_pad_lot_id(self):
|
||||
for item in self:
|
||||
if item.pad_freight_lot_id:
|
||||
item.pad_lot_id = item.pad_freight_lot_id.lot_id.id
|
||||
elif not item.pad_freight_barcode_id:
|
||||
item.pad_lot_id = False
|
||||
|
||||
@api.depends('pad_lot_id')
|
||||
def _compute_pad_product_id(self):
|
||||
@@ -655,11 +663,13 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.chuck_freight_lot_id = False
|
||||
|
||||
@api.depends('chuck_freight_lot_id')
|
||||
@api.depends('chuck_freight_lot_id', 'chuck_freight_barcode_id')
|
||||
def _compute_chuck_lot_id(self):
|
||||
for item in self:
|
||||
if item.chuck_freight_lot_id:
|
||||
item.chuck_lot_id = item.chuck_freight_lot_id.lot_id.id
|
||||
elif not item.chuck_freight_barcode_id:
|
||||
item.chuck_lot_id = False
|
||||
|
||||
@api.depends('chuck_lot_id')
|
||||
def _compute_chuck_product_id(self):
|
||||
@@ -819,7 +829,103 @@ class FunctionalToolAssembly(models.Model):
|
||||
self.after_assembly_coarse_middle_thin = '3'
|
||||
self.after_assembly_new_former = '0'
|
||||
|
||||
# todo 调用功能刀具名称对应的清单的BOM获取对应刀具物料信息
|
||||
# 调用功能刀具名称对应的清单的BOM获取对应刀具物料信息
|
||||
bom = self._get_inventory_bom(self.tool_inventory_id)
|
||||
# 根据BOM自动配置物料的值
|
||||
self._set_tool_material(bom)
|
||||
logging.info('功能刀具开始组装初始化值成功!')
|
||||
|
||||
def _set_tool_material(self, bom):
|
||||
"""根据BOM对刀具物料进行初始配置"""
|
||||
options = bom.get('options')
|
||||
# 配置刀柄信息
|
||||
for handle_id in bom.get('handle_ids'):
|
||||
if handle_id:
|
||||
self.handle_product_id = handle_id.id
|
||||
break
|
||||
|
||||
# 刀柄之外的物料配置
|
||||
if options == '刀柄+整体式刀具':
|
||||
# 配置整体式刀具
|
||||
integra_lot_id = self._get_old_tool_material_lot(bom.get('integral_ids'))
|
||||
integra_location_lot_id = self._get_shelf_location_lot(integra_lot_id)
|
||||
self.integral_freight_barcode_id = integra_location_lot_id.shelf_location_id.id
|
||||
self.integral_freight_lot_id = integra_location_lot_id.id
|
||||
else:
|
||||
# 配置刀片
|
||||
blade_lot_id = self._get_old_tool_material_lot(bom.get('blade_ids'))
|
||||
blade_location_lot_id = self._get_shelf_location_lot(blade_lot_id)
|
||||
self.blade_freight_barcode_id = blade_location_lot_id.shelf_location_id.id
|
||||
self.blade_freight_lot_id = blade_location_lot_id.id
|
||||
|
||||
if options == '刀柄+刀杆+刀片':
|
||||
# 配置刀杆
|
||||
bar_lot_id = self._get_old_tool_material_lot(bom.get('bar_ids'))
|
||||
bar_location_lot_id = self._get_shelf_location_lot(bar_lot_id)
|
||||
self.bar_freight_barcode_id = bar_location_lot_id.shelf_location_id.id
|
||||
self.bar_freight_lot_id = bar_location_lot_id.id
|
||||
elif options == '刀柄+刀盘+刀片':
|
||||
# 配置刀盘
|
||||
pad_lot_id = self._get_old_tool_material_lot(bom.get('pad_ids'))
|
||||
pad_location_lot_id = self._get_shelf_location_lot(pad_lot_id)
|
||||
self.pad_freight_barcode_id = pad_location_lot_id.shelf_location_id.id
|
||||
self.pad_freight_lot_id = pad_location_lot_id.id
|
||||
|
||||
def _get_old_tool_material_lot(self, material_ids):
|
||||
""" 根据先进先出原则选择物料批次 """
|
||||
location_id = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||
stock_quant = self.env['stock.quant'].sudo().search(
|
||||
[('location_id', '=', location_id.id), ('product_id', 'in', material_ids.ids), ('quantity', '>', '0')],
|
||||
order='lot_id', limit=1)
|
||||
if stock_quant:
|
||||
return stock_quant.lot_id
|
||||
else:
|
||||
raise ValidationError(f'【{material_ids[0].cutting_tool_material_id.name}】物料库存不足,请先进行盘点或采购')
|
||||
|
||||
def _get_shelf_location_lot(self, lot_id):
|
||||
"""根据所给的刀具物料批次号,返回一个刀具物料货位、批次信息"""
|
||||
location_lots = self.env['sf.shelf.location.lot'].sudo().search([('lot_id', '=', lot_id.id)])
|
||||
if not location_lots:
|
||||
raise ValidationError(f'没有查询到批次为【{lot_id.name}】物料的货位信息!')
|
||||
else:
|
||||
return location_lots[0]
|
||||
|
||||
def _get_inventory_bom(self, inventory_id):
|
||||
"""获取BOM的刀具物料产品信息"""
|
||||
product_ids = inventory_id.jikimo_bom_ids.product_ids # BOM配置的物料产品
|
||||
options = inventory_id.jikimo_bom_ids.options # BOM产品组装类型
|
||||
|
||||
if not product_ids or not options:
|
||||
raise ValidationError('功能刀具清单的BOM未进行配置,请先配置BOM再开始组装!')
|
||||
handle_ids = product_ids.filtered(lambda a: a.cutting_tool_material_id.name == '刀柄')
|
||||
integral_ids = product_ids.filtered(lambda a: a.cutting_tool_material_id.name == '整体式刀具')
|
||||
blade_ids = product_ids.filtered(lambda a: a.cutting_tool_material_id.name == '刀片')
|
||||
bar_ids = product_ids.filtered(lambda a: a.cutting_tool_material_id.name == '刀杆')
|
||||
pad_ids = product_ids.filtered(lambda a: a.cutting_tool_material_id.name == '刀盘')
|
||||
|
||||
if not handle_ids:
|
||||
raise ValidationError('功能刀具清单的BOM未配置[刀柄]信息,请先配置BOM再开始组装!')
|
||||
|
||||
if options == '刀柄+整体式刀具':
|
||||
if not integral_ids:
|
||||
raise ValidationError('功能刀具清单的BOM未配置[刀柄]信息,请先配置BOM再开始组装!')
|
||||
return {'options': options, 'handle_ids': handle_ids, 'integral_ids': integral_ids}
|
||||
elif options == '刀柄+刀杆+刀片':
|
||||
if not blade_ids:
|
||||
raise ValidationError('功能刀具清单的BOM未配置[刀片]信息,请先配置BOM再开始组装!')
|
||||
if not bar_ids:
|
||||
raise ValidationError('功能刀具清单的BOM未配置[刀杆]信息,请先配置BOM再开始组装!')
|
||||
return {'options': options, 'handle_ids': handle_ids, 'blade_ids': blade_ids, 'bar_ids': bar_ids}
|
||||
elif options == '刀柄+刀盘+刀片':
|
||||
if not blade_ids:
|
||||
raise ValidationError('功能刀具清单的BOM未配置[刀片]信息,请先配置BOM再开始组装!')
|
||||
if not pad_ids:
|
||||
raise ValidationError('功能刀具清单的BOM未配置[刀盘]信息,请先配置BOM再开始组装!')
|
||||
return {'options': options, 'handle_ids': handle_ids, 'blade_ids': blade_ids, 'pad_ids': pad_ids}
|
||||
else:
|
||||
raise ValidationError(f'功能刀具清单BOM的组装方式错误:【{options}】')
|
||||
|
||||
# def set_
|
||||
|
||||
def functional_tool_assembly(self):
|
||||
"""
|
||||
|
||||
@@ -520,81 +520,21 @@
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
<group attrs="{'invisible': [('assemble_status', '=', '0')]}">
|
||||
<group col="1">
|
||||
<div>
|
||||
<separator string="刀柄:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="handle_code_id" string="序列号" placeholder="请选择"
|
||||
options="{'no_create': True, 'no_quick_create': True}"
|
||||
attrs="{'readonly': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="handle_freight_rfid" string="Rfid"/>
|
||||
<field name="handle_product_id" string="名称"/>
|
||||
<field name="cutting_tool_cutterhandle_model_id" string="型号"/>
|
||||
<field name="handle_specification_id" string="规格"/>
|
||||
<field name="sf_tool_brand_id_5" string="品牌"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1"
|
||||
attrs="{'invisible': [('assemble_status', 'not in', ['0','01']),('chuck_product_id', '=', False)]}">
|
||||
<div>
|
||||
<separator string="夹头:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="chuck_freight_barcode_id" string="货位"
|
||||
attrs="{'readonly': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="chuck_freight_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="chuck_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['0','01'])]}"/>
|
||||
<field name="chuck_product_id" string="名称"/>
|
||||
<field name="cutting_tool_cutterhead_model_id" string="型号"/>
|
||||
<field name="chuck_specification_id" string="规格"/>
|
||||
<field name="sf_tool_brand_id_6" string="品牌"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('assemble_status', '=', '0')]}">
|
||||
<group col="1">
|
||||
<group col="1"
|
||||
attrs="{'invisible': [('integral_lot_id', '=', False),'|','|','|', ('blade_lot_id', '!=', False),('bar_lot_id', '!=', False),('pad_lot_id', '!=', False),('assemble_status', 'not in', ['0','01'])]}">
|
||||
<group col="1">
|
||||
<div>
|
||||
<separator string="整体式刀具:" style="font-size: 13px;"/>
|
||||
<separator string="刀柄:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="integral_freight_barcode_id" string="货位"
|
||||
<field name="handle_code_id" string="序列号" placeholder="请选择"
|
||||
options="{'no_create': True, 'no_quick_create': True}"
|
||||
attrs="{'readonly': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="integral_freight_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="integral_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['0','01'])]}"/>
|
||||
<field name="integral_product_id" string="名称"/>
|
||||
<field name="cutting_tool_integral_model_id" string="型号"/>
|
||||
<field name="integral_specification_id" string="规格"/>
|
||||
<field name="sf_tool_brand_id_1" string="品牌"/>
|
||||
<field name="handle_freight_rfid" string="Rfid"/>
|
||||
<field name="handle_product_id" string="名称"/>
|
||||
<field name="cutting_tool_cutterhandle_model_id" string="型号"/>
|
||||
<field name="handle_specification_id" string="规格"/>
|
||||
<field name="sf_tool_brand_id_5" string="品牌"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1"
|
||||
attrs="{'invisible': [('blade_lot_id', '=', False),'|', ('integral_lot_id', '!=', False),('assemble_status', 'not in', ['0','01'])]}">
|
||||
<div>
|
||||
<separator string="刀片:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="blade_freight_barcode_id" string="货位"
|
||||
attrs="{'readonly': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="blade_freight_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="blade_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['0','01'])]}"/>
|
||||
<field name="blade_product_id" string="名称"/>
|
||||
<field name="cutting_tool_blade_model_id" string="型号"/>
|
||||
<field name="blade_specification_id" string="规格"/>
|
||||
<field name="sf_tool_brand_id_2" string="品牌"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1">
|
||||
<group col="1"
|
||||
attrs="{'invisible': [('bar_lot_id', '=', False),'|','|',('integral_lot_id', '!=', False),('pad_lot_id', '!=', False),('assemble_status', 'not in', ['0','01'])]}">
|
||||
<div>
|
||||
@@ -634,6 +574,64 @@
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1">
|
||||
<group col="1"
|
||||
attrs="{'invisible': [('integral_lot_id', '=', False),'|','|','|', ('blade_lot_id', '!=', False),('bar_lot_id', '!=', False),('pad_lot_id', '!=', False),('assemble_status', 'not in', ['0','01'])]}">
|
||||
<div>
|
||||
<separator string="整体式刀具:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="integral_freight_barcode_id" string="货位"
|
||||
attrs="{'readonly': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="integral_freight_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="integral_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['0','01'])]}"/>
|
||||
<field name="integral_product_id" string="名称"/>
|
||||
<field name="cutting_tool_integral_model_id" string="型号"/>
|
||||
<field name="integral_specification_id" string="规格"/>
|
||||
<field name="sf_tool_brand_id_1" string="品牌"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1"
|
||||
attrs="{'invisible': [('blade_lot_id', '=', False),'|', ('integral_lot_id', '!=', False),('assemble_status', 'not in', ['0','01'])]}">
|
||||
<div>
|
||||
<separator string="刀片:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="blade_freight_barcode_id" string="货位"
|
||||
attrs="{'readonly': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="blade_freight_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['1','2'])]}"/>
|
||||
<field name="blade_lot_id" string="批次"
|
||||
attrs="{'invisible': [('assemble_status', 'in', ['0','01'])]}"/>
|
||||
<field name="blade_product_id" string="名称"/>
|
||||
<field name="cutting_tool_blade_model_id" string="型号"/>
|
||||
<field name="blade_specification_id" string="规格"/>
|
||||
<field name="sf_tool_brand_id_2" string="品牌"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<!-- <group col="1"-->
|
||||
<!-- attrs="{'invisible': [('assemble_status', 'not in', ['0','01']),('chuck_product_id', '=', False)]}">-->
|
||||
<!-- <div>-->
|
||||
<!-- <separator string="夹头:" style="font-size: 13px;"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- <group>-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="chuck_freight_barcode_id" string="货位"-->
|
||||
<!-- attrs="{'readonly': [('assemble_status', 'in', ['1','2'])]}"/>-->
|
||||
<!-- <field name="chuck_freight_lot_id" string="批次"-->
|
||||
<!-- attrs="{'invisible': [('assemble_status', 'in', ['1','2'])]}"/>-->
|
||||
<!-- <field name="chuck_lot_id" string="批次"-->
|
||||
<!-- attrs="{'invisible': [('assemble_status', 'in', ['0','01'])]}"/>-->
|
||||
<!-- <field name="chuck_product_id" string="名称"/>-->
|
||||
<!-- <field name="cutting_tool_cutterhead_model_id" string="型号"/>-->
|
||||
<!-- <field name="chuck_specification_id" string="规格"/>-->
|
||||
<!-- <field name="sf_tool_brand_id_6" string="品牌"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- </group>-->
|
||||
<!-- </group>-->
|
||||
</group>
|
||||
<group col="1" attrs="{'invisible': [('assemble_status', '=', '0')]}">
|
||||
<group col="1">
|
||||
|
||||
Reference in New Issue
Block a user