Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Is there a way to reload the BoM into draft Manufacturing Orders?

形象
odoo
形象
丢弃
1 答案
0
形象
odoo
最佳答案

You can create a Server Action that essentially runs the same methods that would run if you created a new Manufacturing Order.  

Be sure to click CREATE CONTEXTUAL ACTION after you've saved it so you can select all your draft MO's in a list and update them in one step:


Updated Answer: v15 (plus carry over the original Quantity):

for record in records:
prior_quantity = record.product_qty
record._onchange_bom_id()
record._onchange_move_raw()
record._onchange_move_finished()
record._onchange_location
record['product_qty'] = prior_quantity


Original Answer: v14:


for record in records:
record._compute_allowed_product_ids()
record._onchange_bom_id()
record._onchange_move_raw()
record._onchange_move_finished()
record._onchange_location
7 注释
形象
丢弃
形象
odoo
-

Hello Ray,
Thank you for your answer !
Would you by chance know what methods to use on Odoo 13.0 ?

形象
odoo
-

Hello Ray,

Do you have an update on this for v15?

Thanks in advance!

形象
odoo
-

For v15, comment out or remove the line "record._compute_allowed_product_ids()"

形象
odoo
-

Thanks Ray, Works like a charm!

形象
odoo
-

Thank you, Ray, for the reply. This was always a bummer.
The only issue is, that the product quantity (product_qty) is always set to 1, which may be wrong.
Also, we would like to update MO's after confirmation as well.

Do you have any idea how to achieve this? (v15

形象
odoo
-

See my updated answer for v15 that changes the quantity after the update from 1 back to the original quantity.

形象
odoo
-

Thanks for the answer. We need to make a little adjustment to your suggestion, because the quantity is getting changed, but the quantity of the raw lines isn't. Writing the quantity right after "(_onchange_bom_id()) fixes that:

for record in records:
prior_quantity = record.product_qty
record._onchange_bom_id()
record['product_qty'] = prior_quantity
record._onchange_move_raw()
record._onchange_move_finished()
record._onchange_location

Now I only need to figure out a way to do this with confirmed MOs or set the state to draft at the beginning and back to confirmed at the end of the server-action. But I couldn't find a pre-defined funtion to set it to draft.