Create triggers are not executed when user is 0

I’m developing a flask application connected to tryton. One of the requirements is to send some mail notification when a new record is created. In order to send this notifications we used the notification_email module in order to setup the templating.

But my surprise is that triggers are skipped when user is root (0), which is the case for web applications.

I’m wondering if there is some special reason for skipping triggers. For me they should be triggered for all users on the system.

They are skipped for root because it is the user of the migration/update. We do not want to trigger business logic during this process.
I think it is not a good idea to use root for normal processes.

So when using flask_tryton to create a web frontend do you recomend to create a specific user for all the requests?

Yes probably (until now we have always used ‘admin’).

If somebody comes across the same issue here is the code we used to set the user:

ModelData = tryton.pool.get('ir.model.data')                                                                                                           
                                                                           
def get_user():                                                                
     with Transaction().start(app.config['TRYTON_DATABASE'], 0):                
         return ModelData.get_id('module', 'xml_id')         
                                                                                          
app.config['TRYTON_USER'] = get_user()

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.