I wanna add specific tag on tag_ids
on ir.attachment
with an Automated Action:
Code:
if record:
if record.res_name and record.res_model_name == 'Task':
key,name = record.res_name.split(" - ")
rec = env['project.task'].search([('key','=',key)])
name_of_task = rec.key +" - " +rec.name
if rec.x_studio_parent_project.x_assign_folder:
if rec.x_studio_level == "IMPLEMENTER":
record._cr.execute("UPDATE ir_attachment SET folder_id = %s WHERE res_name= %s and res_model_name = 'Task'""",(rec.x_studio_parent_project.x_assign_folder.id, name_of_task))
elif rec.x_studio_level == "SUPERVISOR":
record._cr.execute("UPDATE ir_attachment SET folder_id = %s WHERE res_name= %s and res_model_name = 'Task'""",(rec.x_studio_parent_project.x_assign_folder.id, name_of_task))
if rec.project_id.x_assign_folder:
if rec.x_studio_level == "INTERNAL CUSTOMER":
record._cr.execute("UPDATE ir_attachment SET folder_id = %s WHERE res_name= %s and res_model_name = 'Task'""",(rec.project_id.x_assign_folder.id, name_of_task))
The code above is working but i wanna also change the tag id with specific document.facet
id.
Tags = tag_ids: Many2many field
I tried:
record.write({'tag_ids':[66]})
record.write({'tag_ids':[(66)]})
record.tag_ids = [(66)]
record.tag_ids = [66]
record.tag_ids = 66
But none of them working any solution? Thanks in advance
On Many2many field, you can do like this,
record.write({'tag_ids':[(6, 0, [ID])]})
Thanks