This question has been flagged

Hello, I have the applications "Documents" and "Odoo studio" installed.

In "Documents" i have created several workspaces, i want (when i add a new document to a certain workspace that has the word "certificate" in its name) to add a tag (that is already created) automatically via automated actions. Is there a way to do so without the need for developpement and only with ODOO Studio?

I tried to do the following but with no success:

- I created an automated action named "Add tag automatically".
- I set the trigger "on Creation".
- I set the "Action to do" to : Update the record.
- Data to write : 
    * Field: Tags
    * Evaluation type: Value
    * Value : The id of the tag already created, for example: 53 

Is there something I'm doing wrong? 



Avatar
Discard
Best Answer

You can do this by using the Evaluation Type "Python expression" and using the ID of the tag, like this:

[(6,0,[1])] 


Note: The ID of the TAG in my example was 1 so you would use 53 instead of 1.

Avatar
Discard

Thanks Ray, it works but I also would like to understand what `6` and `0` values stand for?

See the answer below. 6 means replace.

Oh, I just missed out. Thank you!

Best Answer

Thx Ray, it works for me. What about to add a new label in second position or third etc ... I have to add more than one label on different condition. I used automated actions using your python expression but each label erase the one before :-(


Edit on 09/05/2022
To add a new tagg, you have to use : [(4,443)] 

on documentation you can read this :

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

6 is option to replace a record, 4 is the opption to update :-)

Avatar
Discard

Hello. Same problem here.

Best Answer

Thanks Robocath, this help me a lot, I am creating check box for to Sales man just click and a tag being created automatically on contact tags, with your explanation works like a charm, just the only thing I need is if the box is uncheck that the tag also be removed, any help here please!!

Avatar
Discard