Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
3314 Visualizzazioni

I need to create a "reset" automated action for unset file which have been uploaded with a form in python code.

At the time this is what I have :

for rec in records:

rec['x_studio_proposition_bu_director'] = False
rec['x_studio_proposition_ceo'] = False
rec['x_studio_legal_proposition_approval'] = False

rec['x_studio_rnd_check'] = False
rec['x_studio_marketing_approval'] = False
rec['x_studio_rnd_comments'] = ""
rec['x_studio_marketing_comments'] = ""

remove(rec['x_studio_quote_file'])
rec['x_studio_proposal_file'] = ""
rec['x_studio_special_legal_attachment'] = ""

I'm trying some tests but I want to unset  x_studio_quote_file, x_studio_proposal_file and x_studio_special_legal_attachment. Other fields are unchecked or text emptied.

,How Can I do that ?
Avatar
Abbandona
Autore

And before empty the fields, possible to copy the name of the file to another field(text by example) or better: create a new empty file field with new label (for keep historic) ?

Thanks Chris !

but  rec['x_studio_proposal_file'] = False doesn't work for delete an attachment

I tested it again in Odoo 12 and 13 and both images and file attachments disappear after the Automated Action is run. I will document it.

Risposta migliore

If you are asking how to delete an attachment, I think the following works:

rec['x_studio_proposal_file'] = False 

If you want to make a copy of the attachments, the simplest way might be to create a copy of the whole record and mark it as archived.  

for rec in records:     
rec['active'] = False old_name = rec.name rec['name'] = rec.name + " (archived)" rec.copy() rec['active'] = True rec['name'] = old_name rec['x_studio_proposal_file'] = False

Screenshots and notes

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
feb 24
1901
1
apr 23
8364
1
dic 24
1225
2
mar 24
1711
2
feb 23
4134