1、创建创建功能刀具该批次/序列号位置

This commit is contained in:
JIKIMO-YXH\xianghui
2023-10-27 17:46:19 +08:00
parent e3d58c2a9e
commit 5b9fcb2e53
3 changed files with 37 additions and 5 deletions

View File

@@ -430,12 +430,36 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
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
})
# 创建功能刀具该批次/序列号位置
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_quant = self.env['stock.quant'].create({
# 'location_id': stock_location.id,
# 'product_id': product_id.id,
# 'lot_id': stock_lot.id,
# 'quantity': 1.0
# })
# # 应用该位置
# bool = stock_quant.action_apply_inventory()
# return stock_quant
def get_stock_lot_name(self):
"""
生成功能刀具序列号
@@ -448,13 +472,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
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)