I am using Odoo 11 and want to notify the user when a certain record is created, not via email but inside Odoo such that there is this thing:
I think this should be fairly simple with Odoo standard features but I don't know how to do it.
What I tried is an Automated Action that adds the users that should be notified as followers (Action To Do: Add Followers,Trigger Condition: On Creation).
Further I inherit in my model from mail.thread
, track several fields, and define a Subtype for them. And this does indeed work to be notified about changes of the fields, but there is no message when the record is created. Why is this? Maybe creation does not count as change? Or Maybe the Automated Action is executed to late because he must be following BEFORE the record is created?
An alternative that I see would be to overwrite the create(...) method and send some message from there. But how to do this? It feels like there is something obvious that I don't see. I mean there is a note that the record was created in the chatter anyway. All I want to do is to have this in a users inbox as message.
Example Code:
class MyModel(models.Model):
_name = 'my_module.my_model'
_inherit = ['mail.thread', 'mail.activity.mixin']
name = fields.Char(string='Name', track_visibility=True)
def _track_subtype(self, init_values):
if 'name' in init_values:
return 'mail.mt_comment'
return super(Alert, self)._track_subtype(init_values)