1、优化产初始化生成功能刀具,解决作业类型无法选择功能刀具的问题;2、优化取消功能刀具组装功能;3、新增功能刀具组装确定后生成功能刀具序列号,生成刀具组装入库单
This commit is contained in:
@@ -392,9 +392,71 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
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'}
|
||||
|
||||
def create_stocking_picking(self, stock_lot):
|
||||
"""
|
||||
创建刀具组装入库单
|
||||
"""
|
||||
# 获取名称为刀具组装入库的作业类型
|
||||
picking_type_id = self.env['stock.picking.type'].sudo().search([('name', '=', '刀具组装入库')])
|
||||
# 创建刀具组装入库单
|
||||
picking_id = self.env['stock.picking'].create({
|
||||
'picking_type_id': picking_type_id.id
|
||||
})
|
||||
# 创建作业详情对象记录,并绑定到刀具组装入库单
|
||||
self.env['stock.move.line'].create({
|
||||
'picking_id': picking_id.id,
|
||||
'product_id': stock_lot.product_id.id,
|
||||
'lot_id': stock_lot.id
|
||||
})
|
||||
# 将刀具组装入库单的状态更改为就绪
|
||||
picking_id.action_confirm()
|
||||
|
||||
def create_assemble_warehouse_receipt(self):
|
||||
"""
|
||||
创建功能刀具批次/序列号记录
|
||||
"""
|
||||
product_id = self.env['product.product'].search([('name', '=', '功能刀具')])
|
||||
|
||||
stock_lot = self.env['stock.lot'].create({
|
||||
'name': self.get_stock_lot_name(),
|
||||
'product_id': product_id.id,
|
||||
'product_qty': 1.00,
|
||||
'company_id': self.env.company.id
|
||||
})
|
||||
|
||||
return stock_lot
|
||||
|
||||
def get_stock_lot_name(self):
|
||||
"""
|
||||
生成功能刀具序列号
|
||||
"""
|
||||
code = 'JKM-T-' + str(self.code) + '-' + str(self.functional_tool_diameter) + '-'
|
||||
new_time = fields.Date.today()
|
||||
code += str(new_time) + '-'
|
||||
stock_lot_id = self.env['stock.lot'].sudo().search(
|
||||
[('name', 'like', new_time), ('product_id.name', '=', '功能刀具')],
|
||||
limit=1,
|
||||
order="id desc"
|
||||
)
|
||||
print(stock_lot_id)
|
||||
if not stock_lot_id:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(stock_lot_id.name[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
print(num)
|
||||
return code + str(num)
|
||||
|
||||
|
||||
class DeliveryOfCargoFromStorage(models.TransientModel):
|
||||
_name = 'sf.delivery.of.cargo.from.storage'
|
||||
|
||||
Reference in New Issue
Block a user