Skip to Content
Menu
This question has been flagged

I want to have the option in action dropdown to bulk duplicate the selected Manufacturing Orders. Is there any way of doing this non-programmatically or programmatically?

What about implementing the functionality to bulk delete and bulk duplicate at the same time?

Avatar
Discard
Best Answer

You would need to create a server action (in settings turn on developer mode then Settings -> Technical -> Server Acrions -> Create) called bulk copy on the manufacturing order that calls python code. 

It should just be

for rec in records:

    rec.copy()        

Once saved, make sure you add a context menu in the top right. Then once you refresh, go to the manufacturing orders, select some and click action at the top. You should now have bulk copy.

To copy then delete, just add rec.unlink() after the last line.      

Avatar
Discard

Very good! But Odoo will only let you delete a Manufacturing Order if the state is "cancel" so you add the following:

rec.copy()

record['state'] = "cancel" <=== Add this

rec.unlink()

Author

Thank you, Jake and Chris, your both replies are very helpful.

I created the server action and it works almost fine. The thing that is not copied was the Source (the origin which refers to the sale order). I managed to copy it as well.

But my question is, why it was not copied? Could it be possible that I lose other data like this and how can I handle it?

My initial purpose to copy and delete MOs is to make it possible to change the Routing in the new MO (since it is not possible after the creation of workorders). Do you think is it a good idea or should I do it in another way?

The field origin is not copied (as per base properties). You can check which fields will be copied by looking at the model definition or field list.

It may be possible to change the model definition so that field is copied, but that's not my area of expertise!

In my opinion, it makes sense that Odoo doesn't copy the origin field (though I understand why you want it)

Best Answer

yes, you can develop it programmatically but not possible non-programmatically.

In list view select the records and using action option you can delete bulk record but for duplicate have to implement this functionality 

Avatar
Discard
Best Answer

If it possible pls try this. https://apps.odoo.com/apps/modules/11.0/dev_bulk_duplicate/

Avatar
Discard
Related Posts Replies Views Activity
3
Aug 24
12874
1
May 24
360
0
May 24
248
2
Jun 23
3133
2
Mar 23
1068