1 答案
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
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.