Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
3368 มุมมอง

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 ?
อวตาร
ละทิ้ง
ผู้เขียน

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.

คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.พ. 24
1985
1
เม.ย. 23
8466
CRM automations แก้ไขแล้ว
1
ธ.ค. 24
1295
2
มี.ค. 24
1792
2
ก.พ. 23
4221