自动操作分配特定 tag_ids
Automated Action assign spesific tag_ids
我想在 ir.attachment
上的 tag_ids
上使用自动操作添加特定标签:
代码:
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))
上面的代码有效,但我还想用特定的 document.facet
id 更改标签 id。
标签 = tag_ids: Many2many field
我试过了:
record.write({'tag_ids':[66]})
record.write({'tag_ids':[(66)]})
record.tag_ids = [(66)]
record.tag_ids = [66]
record.tag_ids = 66
但是 none 他们中有任何解决方案吗?提前致谢
在Many2many字段上,你可以这样做,
record.write({'tag_ids':[(6, 0, [ID])]})
谢谢
对于 many2many 字段,需要 元组 的列表。以下是如何传递元组的列表。
(0, 0, { values }) link to a new record that needs to be created with
the given values dictionary
(1, ID, { values }) update the linked record with id = ID (write
values on it)
(2, ID) remove and delete the linked record with id = ID (calls unlink
on ID, that will delete the object completely, and the link to it as
well)
(3, ID) cut the link to the linked record with id = ID (delete the
relationship between the two objects but does not delete the target
object itself)
(4, ID) link to existing record with id = ID (adds a relationship)
(5) unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs]) replace the list of linked IDs (like using (5) then
(4,ID) for each ID in the list of IDs)
我想在 ir.attachment
上的 tag_ids
上使用自动操作添加特定标签:
代码:
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))
上面的代码有效,但我还想用特定的 document.facet
id 更改标签 id。
标签 = tag_ids: Many2many field
我试过了:
record.write({'tag_ids':[66]})
record.write({'tag_ids':[(66)]})
record.tag_ids = [(66)]
record.tag_ids = [66]
record.tag_ids = 66
但是 none 他们中有任何解决方案吗?提前致谢
在Many2many字段上,你可以这样做,
record.write({'tag_ids':[(6, 0, [ID])]})
谢谢
对于 many2many 字段,需要 元组 的列表。以下是如何传递元组的列表。
(0, 0, { values }) link to a new record that needs to be created with the given values dictionary
(1, ID, { values }) update the linked record with id = ID (write values on it)
(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
(4, ID) link to existing record with id = ID (adds a relationship)
(5) unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)