跳至内容
菜单
此问题已终结
1 回复
4250 查看

Hello I'm using Odoo 13 Community Version.

 

I created automated actions to create a routing and a bom, when i create a new product. 

Now i want that the routing should have the name from the product, that works so far.

 

But I also want that the routing field in the BOM, from the product, has automatically the routing with the created product name.

 

So the routing field needs to have the routing with the name that is the same as the product name.


How can I archive this? Maybe also in the automated action with a python expression?

形象
丢弃
最佳答案

HI,

If you are creating the Routing and BOM from the automated action, you can easily assign the routing to BOM if you use Python Expression. While creating the routing you can assign it to a variable and that variable will have the value like mrp.routing(5) , so using .id you can get the id of the newly created routing.


Then while creating Bill of Materials you can pass this ID.


See the Below Sample,



Python Code:
routing = env['mrp.routing'].create({"name": record.name})
bom = env['mrp.bom'].create(
{"product_tmpl_id": record.product_tmpl_id.id, "routing_id": routing.id, "type": 'normal'})


Thanks



形象
丢弃
编写者

Thank you!

相关帖文 回复 查看 活动
3
4月 24
2126
1
9月 23
1988
5
7月 20
5901
0
3月 17
3131
1
9月 24
1331