Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
7340 Widoki

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?

Awatar
Odrzuć
Najlepsza odpowiedź

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.      

Awatar
Odrzuć

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()

Autor

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)

Najlepsza odpowiedź

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 

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
sie 24
14364
1
maj 24
1321
0
maj 24
1060
2
cze 23
3874
2
mar 23
1942