1、删除功能刀具组装的取消组装功能和出库功能;2、删除功能刀具组装单的单据来源跳转按钮;3、新增组装单编码字段和自动生成编码的方法;4、新增功能刀具序列号,绑定功能刀具产品序列号;5、完成功能刀具组装后的产品入库到位置【组装后】

This commit is contained in:
JIKIMO-YXH\xianghui
2023-10-30 17:43:28 +08:00
parent 5b9fcb2e53
commit deccb6e3cd
3 changed files with 119 additions and 222 deletions

View File

@@ -258,7 +258,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
coarse_middle_thin = fields.Selection([("1", ""), ('2', ''), ('3', '')], string='粗/中/精', default='1')
tool_loading_length = fields.Char(string='装刀长')
new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', required=True, default='1')
new_former = fields.Selection([('0', ''), ('1', '')], string='新/旧', required=True, default='0')
reference_length = fields.Char(string='参考伸出长')
cut_time = fields.Char(string='已切削时间')
cut_length = fields.Char(string='已切削长度')
@@ -269,31 +269,20 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
功能刀具组装
:return:
"""
# 创建组装入库单
# 创建功能刀具批次/序列号记录
stock_lot = self.create_assemble_warehouse_receipt()
# 创建刀具组装入库单
self.create_stocking_picking(stock_lot)
desc_1 = {
'cutting_tool_integral_model_id': self.cutting_tool_integral_model_id.id,
'barcode_id': stock_lot.id,
'integral_code_id': self.integral_code_id.id,
'integral_name': self.integral_name,
'sf_tool_brand_id_1': self.sf_tool_brand_id_1,
'cutting_tool_blade_model_id': self.cutting_tool_blade_model_id.id,
'blade_code_id': self.blade_code_id.id,
'blade_name': self.blade_name,
'sf_tool_brand_id_2': self.sf_tool_brand_id_2,
'cutting_tool_cutterbar_model_id': self.cutting_tool_cutterbar_model_id.id,
'bar_code_id': self.bar_code_id.id,
'bar_name': self.bar_name,
'sf_tool_brand_id_3': self.sf_tool_brand_id_3,
'cutting_tool_cutterpad_model_id': self.cutting_tool_cutterpad_model_id.id,
'pad_code_id': self.pad_code_id.id,
'pad_name': self.pad_name,
'sf_tool_brand_id_4': self.sf_tool_brand_id_4,
'cutting_tool_cutterhandle_model_id': self.cutting_tool_cutterhandle_model_id.id,
'handle_code_id': self.handle_code_id.id,
'handle_name': self.handle_name,
'sf_tool_brand_id_5': self.sf_tool_brand_id_5,
'cutting_tool_cutterhead_model_id': self.cutting_tool_cutterhead_model_id.id,
'chuck_code_id': self.chuck_code_id.id,
'chuck_name': self.chuck_name,
'sf_tool_brand_id_6': self.sf_tool_brand_id_6,
'coarse_middle_thin': self.coarse_middle_thin,
'tool_loading_length': self.tool_loading_length,
'new_former': self.new_former,
@@ -305,15 +294,13 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'tool_loading_person': self.env.user.name,
'tool_loading_time': fields.Datetime.now()
}
functional_tool_assembly = self.env['sf.functional.tool.assembly'].search([
('machine_tool_name_id', '=', self.machine_tool_name_id.id),
('cutter_spacing_code', '=', self.cutter_spacing_code),
('assemble_status', '=', '0'),
])
# print('功能刀具组装id', functional_tool_assembly.id)
# print('整体式物料信息:', self.cutting_tool_integral_model_id.id)
# 封装功能刀具数据
desc_2 = {
'code': self.code,
@@ -384,21 +371,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'applicable_range': record.applicable_range,
'image': record.image,
})
# # 删除功能刀具列表信息
# self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).unlink()
# # 创建功能刀具列表信息
# self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).create(desc_2)
# 修改功能刀具列表信息
self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).write(desc_2)
# 修改功能刀具组装信息
functional_tool_assembly.write(desc_1)
# 创建组装入库单
# 创建功能刀具批次/序列号记录
stock_lot = self.create_assemble_warehouse_receipt()
# 创建刀具组装入库单
self.create_stocking_picking(stock_lot)
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}
@@ -432,33 +409,39 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'product_id': product_id.id,
'company_id': self.env.company.id
})
# 创建功能刀具该批次/序列号位置
# 创建功能刀具该批次/序列号 库存移动和移动历史
self.create_stock_quant(product_id, stock_lot)
return stock_lot
def create_stock_quant(self, product_id, stock_lot):
"""
创建功能刀具该批次/序列号位置
创建功能刀具该批次/序列号 库存移动和移动历史
"""
# 获取组装后位置对象
stock_location = self.env['stock.location'].search([('name', '=', '组装后')])
#
self.env['stock.move'].create({
'':
# 获取位置对象
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
location_inventory_id = self.env['stock.location'].search([('name', '=', 'Inventory adjustment')])
# 创建库存移动
stock_move_id = self.env['stock.move'].create({
'name': '更新的产品数量',
'product_id': product_id.id,
'location_id': location_inventory_id.id,
'location_dest_id': stock_location_id.id,
'product_uom_qty': 1.00,
'state': 'done'
})
# 创建功能刀具该批次/序列号位置
# stock_quant = self.env['stock.quant'].create({
# 'location_id': stock_location.id,
# 'product_id': product_id.id,
# 'lot_id': stock_lot.id,
# 'quantity': 1.0
# })
# 创建移动历史
stock_move_line_id = self.env['stock.move.line'].create({
'product_id': product_id.id,
'lot_id': stock_lot.id,
'move_id': stock_move_id.id,
'qty_done': 1.0,
'state': 'done'
})
# # 应用该位置
# bool = stock_quant.action_apply_inventory()
# return stock_quant
return stock_move_id, stock_move_line_id
def get_stock_lot_name(self):
"""