This question has been flagged
10 Replies
4411 Views

Hello guys,

I would like to add in projects something like this:

once task is moved in to "Done" column automatically send message to the assigned user (followers)

so I tried <attrib="{'invisible':[('stage_id','=','Done')]}"/> to hide/unhide followers which unhided should automatically send message to them.

BUT stage_id = 'Done' doesn't work.

I know I can set stage change for each of them (followers) but it's not what I want.

Any suggestions ?

I already tried this:

<div attrs="{'invisible': [('stage_id','=','Arrived')]}" class="oe_chatter">

<field name="message_ids" attrs="{'invisible': [('stage_id','=','Sorting')]}"/>

<field name="message_follower_ids" groups="base.group_user" attrs="{'invisible': [('stage_id','=','Finished')]}"/>

</div>

Avatar
Discard
Best Answer

Hello,

I couldn't get what you want to achieve ...

for you trial "stage_is = Done doesn't work" :

<attrib={'invisible':[('stage_id', '=', 'Done')]}"/>

you can make a new field to get the name of the stage_id

then make an onchange mehtod on the stage_id to get the name and put it in the new field.

for your field you need to be invisible:

<field name="name" attrs="{'invisible':[('new_field', '=', 'Done')]}"/>

Update:

To make the followers and messaging widget  invisible , add invisible attribute to the div class="oe_chatter"

you can do it by using inheritance by xpath.

if you don't want to add a new field, you can't hide it unless you know the id of the stage.

e.g in the default Odoo data the ID of the Design stage is 3 so your tag will looks like:

<div class="oe_chatter" attrs="{'invisible': [('stage_id','=',3)]}"> 

if you're using xpath:

<attribute name="attrs">{'invisible': [('stage_id','=',3)]}</attribute>

Update:

I made a simple example to you in the GitHub , this will hide the oe_chatter if the stage is in 'Done' Or 'Testing'

you can add your specific stages in this line ...

I hope this can helps you to achieve what you're looking for ...


Kind Regards

Avatar
Discard
Author

Let me enlighten a bit what I'm talking about. In project I have four stages: 1. Purchases 2. Delivered 3. Sorting 4. Done so once I post a task into stage 1 i would like to make followers visible and let the project send message to the followers that new product is ordered and I'm waiting for it. Once I receive it I'll move it to the next stage but I do not want send anything so in this stage Followers needs to be hidden, same in stage 3. At the end if stage will = 'Done' followers will be back visible and message will be send informing followers "this product is ready to be sell" ... something like that. I don't want add any new fields, I would like to do it based on existing fields in Odoo.

Updated my answer ...

Author

Unfortunately it doesn't work neither if I use numbers or Stage names ....

Can you post what you did ?

Author

I already tried this: ..div.. .. attrs="{'invisible': [('stage_id','=','Arrived')]}" class="oe_chatter" /.. ..field name="message_ids" attrs="{'invisible': [('stage_id','=','Sorting')]}"/.. ..field name="message_follower_ids" groups="base.group_user" attrs="{'invisible': [('stage_id','=','Finished')]}"/.. ../div..

Author

so I expected followers to be hidden until stage_id is not equal 'Done'

It'll not work like that, the stage_id doesn't store string value, it is a many2one field so it just handle integer number (ID from the related table). If you'd like to test the invisible is working try attrs="{'invisible': True}", and the chatter will be invisible. To make it work for now[Since you don't want to add a new field and I don't know why], you have to know the ID of the e.g 'Done' stage. In the posgresql make a query "SELECT id FROM project_task_type WHERE name = 'Done';" then you can use this id in your invisible domain as the example in my answer. Just try it and post your update, and if I found spare time I'll try to make a complete example to you since it is not a complicated issue ...

Author

It's interesting. For testing purposes I just added .. field name="stage_id" readonly="1"/.. into the form and it display value stored by this field and it is not a digit but string. Exactly the same value as in the top bar. I tried use stage_id with a numbers "attrs={'invisible':[('stage_id','=',number here)]}" as well but it gives me an error all the time.

Updated my answer ..

Author Best Answer

Here is the code:

On screen you can see "Stage" which is stage_id value

attrs = invisible if stage_id  is "Finished" so "Send message" should be invisible.


 

Avatar
Discard

Updated my answer.

Author

Must say ..... superb. Works damn well :). Also i was thinking that it would be good if I can for example add one more field into the project stage type like send message yes/no so once i set send message to yes when project is on this stage it will send message (show chatter) or not then chatter will not be visible. Hope you know what i mean.