Connectors mailing list archives

connectors@odoo-community.org

Avatar

Re: Odoo Connector, how to fire an on_record_create event

by
Guewen Baconnier
- 07/03/2016 09:40:40
Hi,

Your code seems correct. Did you imported event.py in __init__.py?
What version/revision of the connector addon do you use?

--
Guewen Baconnier
Business Solutions Software Developer

Camptocamp SA
PSE A, CH-1015 Lausanne
Phone: +41 21 619 10 39
Office: +41 21 619 10 10
http://www.camptocamp.com/


On Mon, Mar 7, 2016 at 9:38 AM, Kitti U. <kittiu@ecosoft.co.th> wrote:
> 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_create
> from .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_name
>     for 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
>
> _______________________________________________
> Mailing-List: http://odoo-community.org/groups/connectors-30
> Post to: mailto:connectors@odoo-community.org
> Unsubscribe: http://odoo-community.org/groups?unsubscribe

Reference