多供货方式选择
This commit is contained in:
@@ -4,7 +4,7 @@ from . import controllers
|
|||||||
|
|
||||||
from odoo import api, SUPERUSER_ID
|
from odoo import api, SUPERUSER_ID
|
||||||
|
|
||||||
def _set_init_product_active_false(cr, registry):
|
def _data_install(cr, registry):
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
# 获取所有需要设置的产品模板
|
# 获取所有需要设置的产品模板
|
||||||
env.ref('jikimo_sale_multiple_supply_methods.product_product_purchase').product_tmpl_id.write({'active': False})
|
env.ref('jikimo_sale_multiple_supply_methods.product_product_purchase').product_tmpl_id.write({'active': False})
|
||||||
@@ -12,3 +12,112 @@ def _set_init_product_active_false(cr, registry):
|
|||||||
env.ref('jikimo_sale_multiple_supply_methods.product_product_default').product_tmpl_id.write({'active': False})
|
env.ref('jikimo_sale_multiple_supply_methods.product_product_default').product_tmpl_id.write({'active': False})
|
||||||
env.ref('jikimo_sale_multiple_supply_methods.product_product_raw_material_customer_provided').product_tmpl_id.write({'active': False})
|
env.ref('jikimo_sale_multiple_supply_methods.product_product_raw_material_customer_provided').product_tmpl_id.write({'active': False})
|
||||||
env.ref('jikimo_sale_multiple_supply_methods.product_product_outsourcing').product_tmpl_id.write({'active': False})
|
env.ref('jikimo_sale_multiple_supply_methods.product_product_outsourcing').product_tmpl_id.write({'active': False})
|
||||||
|
# 为三步制造增加规则
|
||||||
|
warehouse = env['stock.warehouse'].search([('company_id', '=', env.company.id)], limit=1)
|
||||||
|
product_route_id = warehouse.pbm_route_id
|
||||||
|
# 创建规则:原料存货区 -> 制造前, 坯料存货区 -> 制造前, 制造后 -> 坯料存货区, 制造后 -> 成品存货区
|
||||||
|
raw_material_location_id = env['stock.location'].search([('name', '=', '坯料存货区')], limit=1)
|
||||||
|
picking_type_production = warehouse.pbm_type_id
|
||||||
|
picking_type_stock = warehouse.sam_type_id
|
||||||
|
material_location_id = env['stock.location'].search([('name', '=', '原料存货区')], limit=1)
|
||||||
|
# 为mto增加规则
|
||||||
|
mto_route_id = env.ref('stock.route_warehouse0_mto')
|
||||||
|
# 创建规则:原料存货区 -> 外包位置, 坯料存货区 -> 外包位置
|
||||||
|
subcontracting_location_id = env.company.subcontracting_location_id
|
||||||
|
picking_type_subcontracting = warehouse.subcontracting_resupply_type_id
|
||||||
|
# 为补给外包商增加规则
|
||||||
|
resupply_route_id = warehouse.subcontracting_route_id
|
||||||
|
|
||||||
|
rules_data = [
|
||||||
|
{
|
||||||
|
'name': 'WH: 原料存货区 → 制造前',
|
||||||
|
'location_src_id': material_location_id.id,
|
||||||
|
'location_dest_id': warehouse.pbm_loc_id.id,
|
||||||
|
'route_id': product_route_id.id,
|
||||||
|
'picking_type_id': picking_type_production.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 20,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'mts_else_mto',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 坯料存货区 → 制造前',
|
||||||
|
'location_src_id': raw_material_location_id.id,
|
||||||
|
'location_dest_id': warehouse.pbm_loc_id.id,
|
||||||
|
'route_id': product_route_id.id,
|
||||||
|
'picking_type_id': picking_type_production.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 21,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'mts_else_mto',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 制造后 → 坯料存货区',
|
||||||
|
'location_src_id': warehouse.sam_loc_id.id,
|
||||||
|
'location_dest_id': raw_material_location_id.id,
|
||||||
|
'route_id': product_route_id.id,
|
||||||
|
'picking_type_id': picking_type_stock.id,
|
||||||
|
'action': 'push',
|
||||||
|
'sequence': 23,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 制造后 → 成品存货区',
|
||||||
|
'location_src_id': warehouse.sam_loc_id.id,
|
||||||
|
'location_dest_id': env['stock.location'].search([('name', '=', '成品存货区')], limit=1).id,
|
||||||
|
'route_id': product_route_id.id,
|
||||||
|
'picking_type_id': picking_type_stock.id,
|
||||||
|
'action': 'push',
|
||||||
|
'sequence': 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 原料存货区 → 外包位置 (MTO)',
|
||||||
|
'location_src_id': material_location_id.id,
|
||||||
|
'location_dest_id': subcontracting_location_id.id,
|
||||||
|
'route_id': mto_route_id.id,
|
||||||
|
'picking_type_id': picking_type_subcontracting.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 24,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'mts_else_mto',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 坯料存货区 → 外包位置 (MTO)',
|
||||||
|
'location_src_id': raw_material_location_id.id,
|
||||||
|
'location_dest_id': subcontracting_location_id.id,
|
||||||
|
'route_id': mto_route_id.id,
|
||||||
|
'picking_type_id': picking_type_subcontracting.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 25,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'mts_else_mto',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 坯料存货区 → 外包位置',
|
||||||
|
'location_src_id': raw_material_location_id.id,
|
||||||
|
'location_dest_id': subcontracting_location_id.id,
|
||||||
|
'route_id': resupply_route_id.id,
|
||||||
|
'picking_type_id': picking_type_subcontracting.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 26,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'make_to_stock',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
# 遍历每个规则数据,执行创建或更新操作
|
||||||
|
for rule_data in rules_data:
|
||||||
|
_create_or_update_stock_rule(env, rule_data)
|
||||||
|
|
||||||
|
def _create_or_update_stock_rule(env, rule_data):
|
||||||
|
# 尝试查找现有的 stock.rule
|
||||||
|
existing_rule = env['stock.rule'].search([
|
||||||
|
('name', '=', rule_data['name']),
|
||||||
|
('route_id', '=', rule_data.get('route_id'))
|
||||||
|
], limit=1)
|
||||||
|
|
||||||
|
if existing_rule:
|
||||||
|
# 如果存在,更新现有记录
|
||||||
|
existing_rule.write(rule_data)
|
||||||
|
else:
|
||||||
|
# 如果不存在,创建新记录
|
||||||
|
env['stock.rule'].create(rule_data)
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
# 'jikimo_sale_multiple_supply_methods/static/src/**/*'
|
# 'jikimo_sale_multiple_supply_methods/static/src/**/*'
|
||||||
# ],
|
# ],
|
||||||
},
|
},
|
||||||
'post_init_hook': '_set_init_product_active_false',
|
'post_init_hook': '_data_install',
|
||||||
'application': True,
|
'application': True,
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
|
|||||||
@@ -28,7 +28,5 @@
|
|||||||
<field name="picking_type_id" ref="material_picking_in"/>
|
<field name="picking_type_id" ref="material_picking_in"/>
|
||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','jikimo_attachment_viewer'],
|
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','jikimo_attachment_viewer', 'jikimo_sale_multiple_supply_methods'],
|
||||||
'data': [
|
'data': [
|
||||||
'data/stock_data.xml',
|
'data/stock_data.xml',
|
||||||
'data/empty_racks_data.xml',
|
'data/empty_racks_data.xml',
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
<xpath expr="//field[@name='user_id']" position="after">
|
<xpath expr="//field[@name='user_id']" position="after">
|
||||||
<field name="production_line_id" readonly="1"/>
|
<field name="production_line_id" readonly="1"/>
|
||||||
<!-- <field name="production_line_state" readonly="1"/>-->
|
<!-- <field name="production_line_state" readonly="1"/>-->
|
||||||
<field name="part_number" string="成品的零件图号"/>
|
<field name="part_number" string="零件图号"/>
|
||||||
<field name="tool_state"/>
|
<field name="tool_state"/>
|
||||||
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
|
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
|
||||||
<field name="deadline_of_delivery" readonly="1"/>
|
<field name="deadline_of_delivery" readonly="1"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user