Odoo Help


How do I configure the subscription types for a follower from Python?

on 3/23/16, 9:57 AM 2,195 views

Hi guys,

I'm creating a webpage from which a project issue will be automatically created. After the project issue is created I will add the customer as a follower with this code:

add_user_as_follower = request.env['mail.followers'].sudo().create({ 'partner_id': partner_id, 'res_model': 'project.issue', 'res_id': new_ticket_id.id })

This works fine and will add the customer as a follower on the issue (by writing in the model mail.followers). However, when I now look at the details of this follower and when he should get notified I can see none of the options are configured:

How can I set the field 'Discussions' checked on by default when I add the customer as a follower? The person that is added as a follower, with the above code, should also recieve e-mails when something is posted on the issue by anybody.
So, on which table should I write what to automatically check on Discussions for this follower?



Shawn Varghese

--Shawn Varghese--
| 5 3 7
Dubai, United Arab Emirates
--Shawn Varghese--

Shawn Varghese
On 3/23/16, 3:34 PM

Hi Yenthe,

Are you referring to the message subtypes? You can normally configure that in the following way:

Example taken from sale.py:


def _track_subtype(self, init_values):


if 'state' in init_values and self.state == 'sale':

return 'sale.mt_order_confirmed'

elif 'state' in init_values and self.state == 'sent':

return 'sale.mt_order_sent'

return super(SaleOrder, self)._track_subtype(init_values)

We use the _track_subtype method to track the state variable. Therefore, whenever the state is changed and moves to 'sale' state, the message subtype sale.mt_order_confirmed is used for the automatic e-mail to followers. This subtype will be defined in XML as :

<record id="mt_order_confirmed" model="mail.message.subtype">

<field name="name">Sales Order Confirmed</field>

<field name="res_model">sale.order</field>

<field name="default" eval="False"/>

<field name="description">Quotation confirmed</field>


Here, if you change the default field value to true, followers of the document will automatically get subscribed to this message type. I imagine something similar will have been done for the Issues module in the screenshot you shared.

Also, the automatic e-mail that gets sent will include details of the changes. You can choose which details to include by using the track_visibility parameter:


     state = fields.Selection([

('draft', 'Quotation'),

('sent', 'Quotation Sent'),

('sale', 'Sale Order'),

('done', 'Done'),

('cancel', 'Cancelled'),

], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange', default='draft')


Hope this is what you were referring to.

Also, isn't the Discussions default to True? I just tried adding a customer as a follower, but I found that they were automatically subscribed to Discussions... Also, if you navigate to Settings > Technical > Subtypes, you can configure which ones should be subscribed by default.

ePillars Systems LLC, Shawn Varghese
on 3/23/16, 3:42 PM

@Shawn thank you for the answer but I'm not talking about the states at the top of a record (the progressbar), I'm talking about the followers on a record and how to automatically give them specific settings. The Discussions its followers are not by default configured by my case because I add them through Python, which I'm doing besides the default behaviour.

on 3/29/16, 3:04 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/23/16, 9:57 AM
Seen: 2195 times
Last updated: 3/31/16, 11:05 AM