Community mailing list archives

community@mail.odoo.com

Re: Odoo Connector, how to fire an on_record_create event.

by
Camptocamp SA, Guewen Baconnier - Software Developer, Camptocamp
- 03/07/2016 02:44:11
Hi,

You should better use the 'Connectors' Mailing list (search for
Connectors on https://odoo-community.org/groups).
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 Sun, Mar 6, 2016 at 10:41 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: https://www.odoo.com/groups/community-59
> Post to: mailto:community@mail.odoo.com
> Unsubscribe: https://www.odoo.com/groups?unsubscribe