Connectors mailing list archives
connectors@odoo-community.org
Browse archives
Odoo Connector, how to fire an on_record_create event
by
Ecosoft Co. Ltd., Kitti Upariphutthiphong
Hi connector experts,
--
To understand how Odoo Connector works. I start writing a simple use case to export a record from Odoo.
My code in event.py,
from openerp.addons.connector.event import on_record_createfrom .unit.export_synchronizer import export_org@on_record_create(model_names=['connector.res.org'])def delay_export_org(session, model_name, record_id, fields=None):export_org.delay(session, model_name, record_id)@on_record_create(model_names=['res.org'])def create_default_binding(session, model_name, record_id, fields=None):
obj = session.env[model_name].browse(record_id)default_backends = session.env['connector.backend'].search([])ic_model_name = 'connector.' + model_namefor backend in default_backends:session.env[ic_model_name].create({'backend_id': backend.id,'openerp_id': obj.id,'exported_record': True})
I assume that @on_record_create is the key, when I create a record in model res.org, the above code should run. But it wasn't.
Anywhere else I have to tell connector in order to fire the event?
Thank you,
Mobile: +66-(0)8-1841-7480
Your ERP Partner => www.ecosoft.co.th
Follow-Ups
-
Re: Odoo Connector, how to fire an on_record_create event
byGuewen Baconnier -
Re: Odoo Connector, how to fire an on_record_create event
byEcosoft Co. Ltd., Kitti Upariphutthiphong