Binders

class openerp.addons.magentoerpconnect.unit.binder.MagentoBinder(connector_env)[source]

Bases: openerp.addons.connector.connector.Binder

Generic Binder for Magento

class openerp.addons.magentoerpconnect.unit.binder.MagentoModelBinder(connector_env)[source]

Bases: openerp.addons.magentoerpconnect.unit.binder.MagentoBinder

Bindings are done directly on the binding model.

Binding models are models called magento.{normal_model}, like magento.res.partner or magento.product.product. They are _inherits of the normal models and contains the Magento ID, the ID of the Magento Backend and the additional fields belonging to the Magento instance.

bind(external_id, binding_id)[source]

Create the link between an external ID and an OpenERP ID and update the last synchronization date.

Parameters:
  • external_id – External ID to bind
  • binding_id (int) – OpenERP ID to bind
to_backend(record_id, wrap=False)[source]

Give the external ID for an OpenERP ID

Parameters:
  • record_id – OpenERP ID for which we want the external id or a recordset with one record
  • wrap – if False, record_id is the ID of the binding, if True, record_id is the ID of the normal record, the method will search the corresponding binding and returns the backend id of the binding
Returns:

backend identifier of the record

to_openerp(external_id, unwrap=False, browse=False)[source]

Give the OpenERP ID for an external ID

Parameters:
  • external_id – external ID for which we want the OpenERP ID
  • unwrap – if True, returns the normal record (the one inherits’ed), else return the binding record
  • browse – if True, returns a recordset
Returns:

a recordset of one record, depending on the value of unwrap, or an empty recordset if no binding is found

Return type:

recordset

unwrap_binding(binding_id, browse=False)[source]

For a binding record, gives the normal record.

Example: when called with a magento.product.product id, it will return the corresponding product.product id.

Parameters:browse – when True, returns a browse_record instance rather than an ID
unwrap_model()[source]

For a binding model, gives the name of the normal model.

Example: when called on a binder for magento.product.product, it will return product.product.

This binder assumes that the normal model lays in openerp_id since this is the field we use in the _inherits bindings.