This question has been flagged
1 Reply
2739 Views

Am using odoo10. In the models/models.py file I have the following:

from connector.event import on_record_create

@on_record_create
def on_create_trigger(session, model_name, record_id, vals):
         print model_name


I have installed the queue_job module and the connector module without errors. But, when I create a new user and hit the save button doesn't print anything. What am I doing wrong?

Avatar
Discard
Author Best Answer

I put my code out of the models module in a file called events.py, then in the init.py added an import for events. Then changed the import in the events.py file, that was wrong. It was as follows:

__init__.py

from . import controllers

from . import models

import events


events.py

from odoo.addons.connector.event import on_record_create

@on_record_create()

def procesa_creacion_de_usuarios(session, model_name, record_id, vals):
       print model_name

And it worked!

Avatar
Discard