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

@@ -38,8 +38,9 @@
<record id="product_functional_tool_sf" model="product.product">
<field name="name">功能刀具</field>
<field name="categ_id" ref="product_category_functional_tool_sf"/>
<field name="route_ids"
eval="[ref('stock.route_warehouse0_mto')]"/>
<!-- <field name="route_ids"-->
<!-- eval="[ref('stock.route_warehouse0_mto')]"/>-->
<field name="route_ids">false</field>
<field name="invoice_policy">delivery</field>
<field name="detailed_type">product</field>
<field name="sale_ok">false</field>

View File

@@ -31,6 +31,15 @@
<field name="company_id" ref="base.main_company"/>
</record>
<!-- <record id="stock_location_locations_WH_tool_stock_area" model="stock.location">-->
<!-- <field name="name">刀具存货区</field>-->
<!-- <field name="location_id" ref="stock.stock_location_locations_virtual"/>-->
<!-- <field name="usage">internal</field>-->
<!-- <field name="barcode">WH-DJCHQ</field>-->
<!-- <field name="active">true</field>-->
<!-- <field name="company_id" ref="base.main_company"/>-->
<!-- </record>-->
<record id="outcontract_picking_in" model="stock.picking.type">
<field name="name">外协入库</field>
<field name="code">internal</field>

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)