Product

class openerp.addons.magentoerpconnect.product.BundleImporter(connector_env)[source]

Bases: openerp.addons.connector.unit.synchronizer.Importer

Can be inherited to change the way the bundle products are imported.

Called at the end of the import of a product.

Example of action when importing a bundle product:
  • Create a bill of material
  • Import the structure of the bundle in new objects

By default, the bundle products are not imported: the jobs are set as failed, because there is no known way to import them. An additional module that implements the import should be installed.

If you want to create a custom importer for the bundles, you have to declare the ConnectorUnit on your backend:

@magento_custom
class XBundleImporter(BundleImporter):
    _model_name = 'magento.product.product'

    # implement import_bundle

If you want to create a generic module that import bundles, you have to replace the current ConnectorUnit:

@magento(replacing=BundleImporter)
class XBundleImporter(BundleImporter):
    _model_name = 'magento.product.product'

    # implement import_bundle

And to add the bundle type in the supported product types:

class magento_product_product(orm.Model):
    _inherit = 'magento.product.product'

    def product_type_get(self, cr, uid, context=None):
        types = super(magento_product_product, self).product_type_get(
            cr, uid, context=context)
        if 'bundle' not in [item[0] for item in types]:
            types.append(('bundle', 'Bundle'))
        return types
run(binding_id, magento_record)[source]

Import the bundle information about a product.

Parameters:magento_record – product information from Magento
class openerp.addons.magentoerpconnect.product.BundleProductImportMapper(connector_env)[source]

Bases: openerp.addons.connector.unit.mapper.ImportMapper

class openerp.addons.magentoerpconnect.product.CatalogImageImporter(connector_env)[source]

Bases: openerp.addons.connector.unit.synchronizer.Importer

Import images for a record.

Usually called from importers, in _after_import. For instance from the products importer.

run(magento_id, binding_id)[source]

Run the synchronization

class openerp.addons.magentoerpconnect.product.IsActiveProductImportMapper(connector_env)[source]

Bases: openerp.addons.connector.unit.mapper.ImportMapper

is_active(record)[source]

Check if the product is active in Magento and set active flag in OpenERP status == 1 in Magento means active

class openerp.addons.magentoerpconnect.product.MagentoProductProduct(pool, cr)[source]

Bases: openerp.models.Model

RECOMPUTE_QTY_STEP = 1000
backorders
Parameters:
  • selection – specifies the possible values for this field. It is given as either a list of pairs (value, string), or a model method, or a method name.
  • selection_add – provides an extension of the selection in the case of an overridden field. It is a list of pairs (value, string).

The attribute selection is mandatory except in the case of related fields or field extensions.

created_at
magento_qty

The precision digits are given by the attribute

Parameters:digits – a pair (total, decimal), or a function taking a database cursor and returning a pair (total, decimal)
manage_stock
Parameters:
  • selection – specifies the possible values for this field. It is given as either a list of pairs (value, string), or a model method, or a method name.
  • selection_add – provides an extension of the selection in the case of an overridden field. It is a list of pairs (value, string).

The attribute selection is mandatory except in the case of related fields or field extensions.

no_stock_sync
openerp_id

The value of such a field is a recordset of size 0 (no record) or 1 (a single record).

Parameters:
  • comodel_name – name of the target model (string)
  • domain – an optional domain to set on candidate values on the client side (domain or string)
  • context – an optional context to use on the client side when handling that field (dictionary)
  • ondelete – what to do when the referred record is deleted; possible values are: 'set null', 'restrict', 'cascade'
  • auto_join – whether JOINs are generated upon search through that field (boolean, by default False)
  • delegate – set it to True to make fields of the target model accessible from the current model (corresponds to _inherits)

The attribute comodel_name is mandatory except in the case of related fields or field extensions.

product_type
Parameters:
  • selection – specifies the possible values for this field. It is given as either a list of pairs (value, string), or a model method, or a method name.
  • selection_add – provides an extension of the selection in the case of an overridden field. It is a list of pairs (value, string).

The attribute selection is mandatory except in the case of related fields or field extensions.

product_type_get(*args, **kwargs)[source]
recompute_magento_qty(*args, **kwargs)[source]

Check if the quantity in the stock location configured on the backend has changed since the last export.

If it has changed, write the updated quantity on magento_qty. The write on magento_qty will trigger an on_record_write event that will create an export job.

It groups the products by backend to avoid to read the backend informations for each product.

updated_at
website_ids

Many2many field; the value of such a field is the recordset.

Parameters:comodel_name – name of the target model (string)

The attribute comodel_name is mandatory except in the case of related fields or field extensions.

Parameters:
  • relation – optional name of the table that stores the relation in the database (string)
  • column1 – optional name of the column referring to “these” records in the table relation (string)
  • column2 – optional name of the column referring to “those” records in the table relation (string)

The attributes relation, column1 and column2 are optional. If not given, names are automatically generated from model names, provided model_name and comodel_name are different!

Parameters:
  • domain – an optional domain to set on candidate values on the client side (domain or string)
  • context – an optional context to use on the client side when handling that field (dictionary)
  • limit – optional limit to use upon read (integer)
class openerp.addons.magentoerpconnect.product.PriceProductImportMapper(connector_env)[source]

Bases: openerp.addons.connector.unit.mapper.ImportMapper

price(record)[source]
openerp.addons.magentoerpconnect.product.ProductBatchImport

alias of openerp.addons.magentoerpconnect.product.ProductBatchImporter

class openerp.addons.magentoerpconnect.product.ProductBatchImporter(connector_env)[source]

Bases: openerp.addons.magentoerpconnect.unit.import_synchronizer.DelayedBatchImporter

Import the Magento Products.

For every product category in the list, a delayed job is created. Import from a date

run(filters=None)[source]

Run the synchronization

openerp.addons.magentoerpconnect.product.ProductImport

alias of openerp.addons.magentoerpconnect.product.ProductImporter

class openerp.addons.magentoerpconnect.product.ProductImportMapper(connector_env)[source]

Bases: openerp.addons.connector.unit.mapper.ImportMapper

backend_id(record)[source]
bundle_mapping(record)[source]
categories(record)[source]
direct = [('name', 'name'), ('description', 'description'), ('weight', 'weight'), ('cost', 'standard_price'), ('short_description', 'description_sale'), ('sku', 'default_code'), ('type_id', 'product_type'), (<function modifier>, 'created_at'), (<function modifier>, 'updated_at')]
is_active(record)[source]
magento_id(record)[source]
openerp_id(record)[source]

Will bind the product to an existing one with the same code

price(record)[source]
type(record)[source]
website_ids(record)[source]
class openerp.addons.magentoerpconnect.product.ProductImporter(connector_env)[source]

Bases: openerp.addons.magentoerpconnect.unit.import_synchronizer.MagentoImporter

openerp.addons.magentoerpconnect.product.ProductInventoryExport

alias of openerp.addons.magentoerpconnect.product.ProductInventoryExporter

class openerp.addons.magentoerpconnect.product.ProductInventoryExporter(connector_env)[source]

Bases: openerp.addons.connector.unit.synchronizer.Exporter

run(binding_id, fields)[source]

Export the product inventory to Magento

class openerp.addons.magentoerpconnect.product.ProductProduct(pool, cr)[source]

Bases: openerp.models.Model

magento_bind_ids

One2many field; the value of such a field is the recordset of all the records in comodel_name such that the field inverse_name is equal to the current record.

Parameters:
  • comodel_name – name of the target model (string)
  • inverse_name – name of the inverse Many2one field in comodel_name (string)
  • domain – an optional domain to set on candidate values on the client side (domain or string)
  • context – an optional context to use on the client side when handling that field (dictionary)
  • auto_join – whether JOINs are generated upon search through that field (boolean, by default False)
  • limit – optional limit to use upon read (integer)

The attributes comodel_name and inverse_name are mandatory except in the case of related fields or field extensions.

class openerp.addons.magentoerpconnect.product.ProductProductAdapter(connector_env)[source]

Bases: openerp.addons.magentoerpconnect.unit.backend_adapter.GenericAdapter

get_images(id, storeview_id=None)[source]
read(id, storeview_id=None, attributes=None)[source]

Returns the information of a record

Return type:dict
read_image(id, image_name, storeview_id=None)[source]
search(filters=None, from_date=None, to_date=None)[source]

Search records according to some criteria and returns a list of ids

Return type:list
update_inventory(id, data)[source]
write(id, data, storeview_id=None)[source]

Update records on the external system

openerp.addons.magentoerpconnect.product.chunks(items, length)[source]
openerp.addons.magentoerpconnect.product.export_product_inventory(session, model_name, record_id, fields=None)[source]

Export the inventory configuration and quantity of a product.

openerp.addons.magentoerpconnect.product.magento_product_modified(session, model_name, record_id, vals)[source]
openerp.addons.magentoerpconnect.product.unwrap_binding(session, job, id_pos=2)

Open a form view with the unwrapped record.

For instance, for a job on a magento.product.product, it will open a product.product form view with the unwrapped record.

Parameters:
  • id_pos – position of the binding ID in the args
  • binder_class – base class to search for the binder