Models

Implementation of the components per model.

Base Models

Magento Backend

class odoo.addons.connector_magento.models.magento_backend.common.MagentoBackend(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.backend'
_description = 'Magento Backend'
_inherit = 'connector.backend'
select_versions()[source]

Available versions in the backend.

Can be inherited to add custom versions. Using this method to add a version from an _inherit does not constrain to redefine the version field in the _inherit model.

_get_stock_field_id()[source]
version
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.

location

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
admin_location

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
use_custom_api_path
username

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
password

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
use_auth_basic
auth_basic_username

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
auth_basic_password

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
sale_prefix

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
warehouse_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.

company_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.

website_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.

default_lang_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.

default_category_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.

import_products_from_date
import_categories_from_date
product_stock_field_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_binding_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.

account_analytic_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.

fiscal_position_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.

is_multi_company
_sql_constraints = [('sale_prefix_uniq', 'unique(sale_prefix)', 'A backend with the same sale prefix already exists')]
check_magento_structure()[source]

Used in each data import.

Verify if a website exists for each backend before starting the import.

work_on(*args, **kwds)[source]
add_checkpoint(record)[source]
synchronize_metadata()[source]
import_partners()[source]

Import partners from all websites

import_sale_orders()[source]

Import sale orders from all store views

import_customer_groups()[source]
_import_from_date(model, from_date_field)[source]
import_product_categories()[source]
import_product_product()[source]
_domain_for_update_product_stock_qty()[source]
update_product_stock_qty()[source]
_magento_backend(callback, domain=None)[source]
_scheduler_import_sale_orders(domain=None)[source]
_scheduler_import_customer_groups(domain=None)[source]
_scheduler_import_partners(domain=None)[source]
_scheduler_import_product_categories(domain=None)[source]
_scheduler_import_product_product(domain=None)[source]
_scheduler_update_product_stock_qty(domain=None)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_backend.common.MagentoConfigSpecializer(pool, cr)[source]

Bases: odoo.models.BaseModel

_name = 'magento.config.specializer'
specific_account_analytic_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.

specific_fiscal_position_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.

specific_warehouse_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.

account_analytic_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.

fiscal_position_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.

warehouse_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.

_parent
_compute_account_analytic_id()[source]
_compute_fiscal_position_id()[source]
_compute_warehouse_id()[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_backend.importer.MetadataBatchImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Import the records directly, without delaying the jobs.

Import the Magento Websites, Stores, Storeviews

They are imported directly because this is a rare and fast operation, and we don’t really bother if it blocks the UI during this time. (that’s also a mean to rapidly check the connectivity with Magento).

_name = 'magento.metadata.batch.importer'
_inherit = 'magento.direct.batch.importer'
_apply_on = ['magento.website', 'magento.store', 'magento.storeview']
_module = 'connector_magento'

Magento Website

class odoo.addons.connector_magento.models.magento_website.common.MagentoWebsite(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.website'
_inherit = ['magento.binding', 'magento.config.specializer']
_description = 'Magento Website'
_parent_name = 'backend_id'
_order = 'sort_order ASC, id ASC'
name

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
code

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
sort_order
store_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.

import_partners_from_date
product_binding_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)
is_multi_company
import_partners()[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_website.common.WebsiteAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.website.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.website'
_magento_model = 'ol_websites'
_admin_path = 'system_store/editWebsite/website_id/{id}'
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_website.importer.WebsiteImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.website.mapper'
_inherit = 'magento.import.mapper'
_apply_on = 'magento.website'
direct = [('code', 'code'), ('sort_order', 'sort_order')]
name(record)[source]
backend_id(record)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_website.importer.MagentoWebsiteImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Import one Magento Website

_name = 'magento.website.record.importer'
_inherit = 'magento.importer'
_apply_on = ['magento.website']
_module = 'connector_magento'

Magento Store

class odoo.addons.connector_magento.models.magento_store.common.MagentoStore(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.store'
_inherit = ['magento.binding', 'magento.config.specializer']
_description = 'Magento Store'
_parent_name = 'website_id'
name

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
website_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.

backend_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.

storeview_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.

send_picking_done_mail
send_invoice_paid_mail
create_invoice_on
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.

is_multi_company
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_store.common.StoreAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.store.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.store'
_magento_model = 'ol_groups'
_admin_path = 'system_store/editGroup/group_id/{id}'
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_store.importer.StoreImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.store.mapper'
_inherit = 'magento.import.mapper'
_apply_on = 'magento.store'
direct = [('name', 'name')]
website_id(record)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_store.importer.StoreImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Import one Magento Store (create a sale.shop via _inherits)

_name = 'magento.store.importer'
_inherit = 'magento.importer'
_apply_on = 'magento.store'
_create(data)[source]
_module = 'connector_magento'

Magento Storeview

class odoo.addons.connector_magento.models.magento_storeview.common.MagentoStoreview(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.storeview'
_inherit = ['magento.binding', 'magento.config.specializer']
_description = 'Magento Storeview'
_parent_name = 'store_id'
_order = 'sort_order ASC, id ASC'
name

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
code

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
enabled
sort_order
store_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.

lang_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.

team_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.

backend_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.

import_orders_from_date
no_sales_order_sync
catalog_price_tax_included
is_multi_company
import_sale_orders()[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_storeview.common.StoreviewAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.storeview.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.storeview'
_magento_model = 'ol_storeviews'
_admin_path = 'system_store/editStore/store_id/{id}'
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_storeview.importer.MagentoStoreviewImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.storeview.mapper'
_inherit = 'magento.import.mapper'
_apply_on = 'magento.storeview'
direct = [('name', 'name'), ('code', 'code'), ('is_active', 'enabled'), ('sort_order', 'sort_order')]
store_id(record)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.magento_storeview.importer.StoreviewImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Import one Magento Storeview

_name = 'magento.storeview.importer'
_inherit = 'magento.importer'
_apply_on = 'magento.storeview'
_create(data)[source]
_module = 'connector_magento'

Magento Binding

class odoo.addons.connector_magento.models.magento_binding.common.MagentoBinding(pool, cr)[source]

Bases: odoo.models.BaseModel

Abstract Model for the Bindings.

All the models used as bindings between Magento and Odoo (magento.res.partner, magento.product.product, …) should _inherit it.

_name = 'magento.binding'
_inherit = 'external.binding'
_description = 'Magento Binding (abstract)'
backend_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.

external_id

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
_sql_constraints = [('magento_uniq', 'unique(backend_id, external_id)', 'A binding already exists with the same Magento ID.')]
import_batch(backend, filters=None)[source]

Prepare the import of records modified on Magento

import_record(backend, external_id, force=False)[source]

Import a Magento record

export_record(fields=None)[source]

Export a record on Magento

export_delete_record(backend, external_id)[source]

Delete a record on Magento

_module = 'connector_magento'

Queue Job

class odoo.addons.connector_magento.models.queue_job.common.QueueJob(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'queue.job'

Open a Magento URL on the admin page to view/edit the record related to the job.

_module = 'connector_magento'

Payment Mode

class odoo.addons.connector_magento.models.account_payment_mode.common.AccountPaymentMode(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'account.payment.mode'
create_invoice_on
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.

_module = 'connector_magento'

Delivery Method

class odoo.addons.connector_magento.models.delivery.common.DeliveryCarrier(pool, cr)[source]

Bases: odoo.models.Model

Adds Magento specific fields to delivery.carrier

magento_code

Code of the carrier delivery method in Magento. Example: colissimo_express

magento_tracking_title

Display name of the carrier for the tracking in Magento. Example: Colissimo Express

magento_carrier_code

General code of the carrier, the first part of the magento_code. Example: colissimo for the method colissimo_express.

magento_export_tracking

Defines if the tracking numbers should be exported to Magento.
_inherit = 'delivery.carrier'
magento_code

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
magento_tracking_title

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
magento_carrier_code

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
magento_export_tracking
_compute_carrier_code()[source]
_module = 'connector_magento'

Synchronized Models

Invoice

class odoo.addons.connector_magento.models.account_invoice.common.MagentoAccountInvoice(pool, cr)[source]

Bases: odoo.models.Model

Binding Model for the Magento Invoice

_name = 'magento.account.invoice'
_inherit = 'magento.binding'
_inherits = {'account.invoice': 'odoo_id'}
_description = 'Magento Invoice'
odoo_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.

magento_order_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.

_sql_constraints = [('odoo_uniq', 'unique(backend_id, odoo_id)', 'A Magento binding for this invoice already exists.')]
export_record()[source]

Export a validated or paid invoice.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.account_invoice.common.AccountInvoice(pool, cr)[source]

Bases: odoo.models.Model

Adds the one2many relation to the Magento bindings (magento_bind_ids)

_inherit = 'account.invoice'
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.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.account_invoice.common.AccountInvoiceAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

Backend Adapter for the Magento Invoice

_name = 'magento.invoice.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.account.invoice'
_magento_model = 'sales_order_invoice'
_admin_path = 'sales_invoice/view/invoice_id/{id}'
_call(method, arguments)[source]
create(order_increment_id, items, comment, email, include_comment)[source]

Create a record on the external system

search_read(filters=None, order_id=None)[source]

Search records according to some criterias and returns their information

Parameters:order_id – ‘order_id’ field of the magento sale order, this is not the same field than ‘increment_id’
_module = 'connector_magento'
class odoo.addons.connector_magento.models.account_invoice.common.MagentoBindingInvoiceListener(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.binding.account.invoice.listener'
_inherit = 'base.event.listener'
_apply_on = ['magento.account.invoice']
on_record_create(record, fields=None)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.account_invoice.common.MagentoInvoiceListener(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.account.invoice.listener'
_inherit = 'base.event.listener'
_apply_on = ['account.invoice']
on_invoice_paid(record)[source]
on_invoice_validated(record)[source]
invoice_create_bindings(invoice)[source]

Create a magento.account.invoice record. This record will then be exported to Magento.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.account_invoice.exporter.MagentoInvoiceExporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Export invoices to Magento

_name = 'magento.account.invoice.exporter'
_inherit = 'magento.exporter'
_apply_on = ['magento.account.invoice']
_export_invoice(external_id, lines_info, mail_notification)[source]
_get_lines_info(invoice)[source]

Get the line to export to Magento. In case some lines doesn’t have a matching on Magento, we ignore them. This allow to add lines manually.

Parameters:invoice (browse_record) – invoice is an magento.account.invoice record
Returns:dict of {magento_product_id: quantity}
Return type:dict
run(binding)[source]

Run the job to export the validated/paid invoice

_get_existing_invoice(magento_order)[source]
_module = 'connector_magento'

Partner

class odoo.addons.connector_magento.models.partner.common.ResPartner(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'res.partner'
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.

magento_address_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.

birthday
company

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
_address_fields()[source]

Returns the list of address fields that are synced from the parent.

import_batch(backend, filters=None)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.common.MagentoResPartner(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.res.partner'
_inherit = 'magento.binding'
_inherits = {'res.partner': 'odoo_id'}
_description = 'Magento Partner'
_rec_name = 'name'
odoo_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.

backend_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.

website_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.

group_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.

created_at
updated_at
emailid

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
taxvat

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
newsletter
guest_customer
consider_as_company
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.common.MagentoAddress(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.address'
_inherit = 'magento.binding'
_inherits = {'res.partner': 'odoo_id'}
_description = 'Magento Address'
_rec_name = 'backend_id'
odoo_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.

created_at
updated_at
is_default_billing
is_default_shipping
magento_partner_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.

backend_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.

website_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.

is_magento_order_address
_sql_constraints = [('odoo_uniq', 'unique(backend_id, odoo_id)', 'A partner address can only have one binding by backend.')]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.common.PartnerAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.partner.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.res.partner'
_magento_model = 'customer'
_admin_path = '/{model}/edit/id/{id}'
_call(method, arguments)[source]
search(filters=None, from_date=None, to_date=None, magento_website_ids=None)[source]

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

Return type:list
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.common.AddressAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.address.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.address'
_magento_model = 'customer_address'
search(filters=None)[source]

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

Return type:list
create(customer_id, data)[source]

Create a record on the external system

_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.importer.PartnerBatchImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Import the Magento Partners.

For every partner in the list, a delayed job is created.

_name = 'magento.partner.batch.importer'
_inherit = 'magento.delayed.batch.importer'
_apply_on = 'magento.res.partner'
run(filters=None)[source]

Run the synchronization

_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.importer.PartnerImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.partner.import.mapper'
_inherit = 'magento.import.mapper'
_apply_on = 'magento.res.partner'
direct = [('email', 'email'), ('dob', 'birthday'), (<function modifier>, 'created_at'), (<function modifier>, 'updated_at'), ('email', 'emailid'), ('taxvat', 'taxvat'), ('group_id', 'group_id')]
is_company(record)[source]
names(record)[source]
customer_group_id(record)[source]
website_id(record)[source]
company_id(record)[source]
lang(record)[source]
customer(record)[source]
type(record)[source]
odoo_id(record)[source]

Will bind the customer on a existing partner with the same email

_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.importer.PartnerImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.partner.importer'
_inherit = 'magento.importer'
_apply_on = 'magento.res.partner'
_import_dependencies()[source]

Import the dependencies for the record

_after_import(partner_binding)[source]

Import the addresses

_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.importer.AddressInfos(magento_record, partner_binding_id, merge)

Bases: tuple

_asdict()

Return a new OrderedDict which maps field names to their values

_fields = ('magento_record', 'partner_binding_id', 'merge')
classmethod _make(iterable, new=<built-in method __new__ of type object at 0x908840>, len=<built-in function len>)

Make a new AddressInfos object from a sequence or iterable

_replace(_self, **kwds)

Return a new AddressInfos object replacing specified fields with new values

magento_record

Alias for field number 0

merge

Alias for field number 2

partner_binding_id

Alias for field number 1

class odoo.addons.connector_magento.models.partner.importer.PartnerAddressBook(work_context)[source]

Bases: odoo.addons.component.core.Component

Import all addresses from the address book of a customer.

This class is responsible to define which addresses should be imported and how (merge with the partner or not…). Then, it delegate the import to the appropriate importer.

This is really intricate. The datamodel are different between Magento and Odoo and we have many uses cases to cover.

The first thing is that:
  • we do not import companies and individuals the same manner
  • we do not know if an account is a company -> we assume that if we found something in the company field of the billing address, the whole account is a company.
Differences:
  • Individuals: we merge the billing address with the partner, so we’ll end with 1 entity if the customer has 1 address
  • Companies: we never merge the addresses with the partner, but we use the company name of the billing address as name of the partner. We also copy the address informations from the billing address as default values.

More information on: https://bugs.launchpad.net/openerp-connector/+bug/1193281

_name = 'magento.address.book'
_inherit = 'base.magento.connector'
_apply_on = 'magento.address'
_usage = 'address.book'
import_addresses(magento_partner_id, partner_binding_id)[source]
_get_address_infos(magento_partner_id, partner_binding_id)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.importer.BaseAddressImportMapper(work_context)[source]

Bases: odoo.addons.component.core.AbstractComponent

Defines the base mappings for the imports in res.partner (state, country, …)

_name = 'magento.base.address.import.mapper'
_inherit = 'magento.import.mapper'
direct = [('postcode', 'zip'), ('city', 'city'), ('telephone', 'phone'), ('fax', 'fax'), ('company', 'company')]
state(record)[source]
country(record)[source]
street(record)[source]
title(record)[source]
company_id(record)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.importer.CompanyImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

Special mapping used when we import a company. A company is considered as such when the billing address of an account has something in the ‘company’ field.

This is a very special mapping not used in the same way than the other.

The billing address will exist as a contact, but we want to copy the data on the company.

The input record is the billing address. The mapper returns data which will be written on the main partner, in other words, the company.

The @only_create decorator would not have any effect here because the mapper is always called for updates.

_name = 'magento.company.import.mapper'
_inherit = 'magento.base.address.import.mapper'
_apply_on = 'magento.res.partner'
_usage = 'company.import.mapper'
direct
consider_as_company(record)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.importer.AddressImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.address.importer'
_inherit = 'magento.importer'
_apply_on = 'magento.address'
run(external_id, address_infos=None, force=False)[source]

Run the synchronization

_get_magento_data()[source]

Return the raw Magento data for self.external_id

_define_partner_relationship(data)[source]

Link address with partner or parent company.

_create(data)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner.importer.AddressImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.address.import.mapper'
_inherit = 'magento.base.address.import.mapper'
_apply_on = 'magento.address'
direct
names(record)[source]
type(record)[source]
_module = 'connector_magento'

Partner Category

class odoo.addons.connector_magento.models.partner_category.common.ResPartnerCategory(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'res.partner.category'
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.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner_category.common.MagentoResPartnerCategory(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.res.partner.category'
_inherit = 'magento.binding'
_inherits = {'res.partner.category': 'odoo_id'}
odoo_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.

tax_class_id
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner_category.common.PartnerCategoryAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.partner.category.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.res.partner.category'
_magento_model = 'ol_customer_groups'
_admin_path = '/customer_group/edit/id/{id}'
search(filters=None)[source]

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

Return type:list
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner_category.importer.PartnerCategoryBatchImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Delay import of the records

_name = 'magento.partner.category.batch.importer'
_inherit = 'magento.delayed.batch.importer'
_apply_on = 'magento.res.partner.category'
_module = 'connector_magento'
class odoo.addons.connector_magento.models.partner_category.importer.PartnerCategoryImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.partner.category.import.mapper'
_inherit = 'magento.import.mapper'
_apply_on = 'magento.res.partner.category'
direct = [('customer_group_code', 'name'), ('tax_class_id', 'tax_class_id')]
external_id(record)[source]
backend_id(record)[source]
odoo_id(record)[source]

Will bind the category on a existing one with the same name.

_module = 'connector_magento'

Product

odoo.addons.connector_magento.models.product.common.chunks(items, length)[source]
class odoo.addons.connector_magento.models.product.common.MagentoProductProduct(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.product.product'
_inherit = 'magento.binding'
_inherits = {'product.product': 'odoo_id'}
_description = 'Magento Product'
product_type_get()[source]
odoo_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.

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)
created_at
updated_at
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.

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.

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.

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)
no_stock_sync
RECOMPUTE_QTY_STEP = 1000
export_inventory(fields=None)[source]

Export the inventory configuration and quantity of a product.

recompute_magento_qty()[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.

_recompute_magento_qty_backend(backend, products, read_fields=None)[source]

Recompute the products quantity for one backend.

If field names are passed in read_fields (as a list), they will be read in the product that is used in _magento_qty().

_magento_qty(product, backend, location, stock_field)[source]

Return the current quantity for one product.

Can be inherited to change the way the quantity is computed, according to a backend / location.

If you need to read additional fields on the product, see the read_fields argument of _recompute_magento_qty_backend()

_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.common.ProductProduct(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'product.product'
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.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.common.ProductProductAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.product.product.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.product.product'
_magento_model = 'catalog_product'
_admin_path = '/{model}/edit/id/{id}'
_call(method, arguments)[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
read(id, storeview_id=None, attributes=None)[source]

Returns the information of a record

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

Update records on the external system

get_images(id, storeview_id=None)[source]
read_image(id, image_name, storeview_id=None)[source]
update_inventory(id, data)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.common.MagentoBindingProductListener(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.binding.product.product.listener'
_inherit = 'base.connector.listener'
_apply_on = ['magento.product.product']
INVENTORY_FIELDS = ('manage_stock', 'backorders', 'magento_qty')
on_record_write(*args, **kwargs)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.importer.ProductBatchImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Import the Magento Products.

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

_name = 'magento.product.product.batch.importer'
_inherit = 'magento.delayed.batch.importer'
_apply_on = ['magento.product.product']
run(filters=None)[source]

Run the synchronization

_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.importer.CatalogImageImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Import images for a record.

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

_name = 'magento.product.image.importer'
_inherit = 'magento.importer'
_apply_on = ['magento.product.product']
_usage = 'product.image.importer'
_get_images(storeview_id=None)[source]
_sort_images(images)[source]

Returns a list of images sorted by their priority. An image with the ‘image’ type is the the primary one. The other images are sorted by their position.

The returned list is reversed, the items at the end of the list have the higher priority.

_get_binary_image(image_data)[source]
_write_image_data(binding, binary, image_data)[source]
run(external_id, binding)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.importer.BundleImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

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 inherit the Component:

class BundleImporter(Component):
    _inherit = 'magento.product.bundle.importer'

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

class MagentoProductProduct(models.Model):
    _inherit = 'magento.product.product'

    @api.model
    def product_type_get(self):
        types = super(MagentoProductProduct, self).product_type_get()
        if 'bundle' not in [item[0] for item in types]:
            types.append(('bundle', 'Bundle'))
        return types
_name = 'magento.product.bundle.importer'
_inherit = 'magento.importer'
_apply_on = ['magento.product.product']
_usage = 'product.bundle.importer'
run(binding, magento_record)[source]

Import the bundle information about a product.

Parameters:magento_record – product information from Magento
_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.importer.ProductImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.product.product.import.mapper'
_inherit = 'magento.import.mapper'
_apply_on = ['magento.product.product']
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]

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

price(record)[source]
type(record)[source]
website_ids(record)[source]
categories(record)[source]
backend_id(record)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.importer.ProductImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.product.product.importer'
_inherit = 'magento.importer'
_apply_on = ['magento.product.product']
_import_bundle_dependencies()[source]

Import the dependencies for a Bundle

_import_dependencies()[source]

Import the dependencies for the record

_validate_product_type(data)[source]

Check if the product type is in the selection (so we can prevent the except_orm and display a better error message).

_must_skip()[source]

Hook called right after we read the data from the backend.

If the method returns a message giving a reason for the skipping, the import will be interrupted and the message recorded in the job (if the import is called directly by the job, not by dependencies).

If it returns None, the import will continue normally.

Returns:None | str | unicode
_validate_data(data)[source]

Check if the values to import are correct

Pro-actively check before the _create or _update if some fields are missing or invalid

Raise InvalidDataError

_create(data)[source]
_after_import(binding)[source]

Hook called at the end of the import

_module = 'connector_magento'
class odoo.addons.connector_magento.models.product.importer.ProductInventoryExporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.product.product.exporter'
_inherit = 'magento.exporter'
_apply_on = ['magento.product.product']
_usage = 'product.inventory.exporter'
_map_backorders = {'use_default': 0, 'yes': 1, 'yes-and-notification': 2, 'no': 0}
_get_data(binding, fields)[source]
run(binding, fields)[source]

Export the product inventory to Magento

_module = 'connector_magento'

Product Category

class odoo.addons.connector_magento.models.product_category.common.MagentoProductCategory(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.product.category'
_inherit = 'magento.binding'
_inherits = {'product.category': 'odoo_id'}
_description = 'Magento Product Category'
odoo_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.

description

Very similar to Char but used for longer contents, does not have a size and usually displayed as a multiline text box.

Parameters:translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
magento_parent_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.

magento_child_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.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.product_category.common.ProductCategory(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'product.category'
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.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.product_category.common.ProductCategoryAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.product.category.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.product.category'
_magento_model = 'catalog_category'
_admin_path = '/{model}/index/'
_call(method, arguments)[source]
search(filters=None, from_date=None, to_date=None)[source]

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

Return type:list
read(id, storeview_id=None, attributes=None)[source]

Returns the information of a record

Return type:dict
tree(parent_id=None, storeview_id=None)[source]

Returns a tree of product categories

Return type:dict
move(categ_id, parent_id, after_categ_id=None)[source]
get_assigned_product(categ_id)[source]
assign_product(categ_id, product_id, position=0)[source]
update_product(categ_id, product_id, position=0)[source]
remove_product(categ_id, product_id)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.product_category.importer.ProductCategoryBatchImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

Import the Magento Product Categories.

For every product category in the list, a delayed job is created. A priority is set on the jobs according to their level to rise the chance to have the top level categories imported first.

_name = 'magento.product.category.batch.importer'
_inherit = 'magento.delayed.batch.importer'
_apply_on = ['magento.product.category']
_import_record(external_id, job_options=None)[source]

Delay a job for the import

run(filters=None)[source]

Run the synchronization

_module = 'connector_magento'
class odoo.addons.connector_magento.models.product_category.importer.ProductCategoryImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.product.category.importer'
_inherit = 'magento.importer'
_apply_on = ['magento.product.category']
_import_dependencies()[source]

Import the dependencies for the record

_create(data)[source]
_after_import(binding)[source]

Hook called at the end of the import

_module = 'connector_magento'
class odoo.addons.connector_magento.models.product_category.importer.ProductCategoryImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.product.category.import.mapper'
_inherit = 'magento.import.mapper'
_apply_on = 'magento.product.category'
direct = [('description', 'description')]
name(record)[source]
backend_id(record)[source]
parent_id(record)[source]
_module = 'connector_magento'

Sales Order

class odoo.addons.connector_magento.models.sale_order.common.MagentoSaleOrder(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.sale.order'
_inherit = 'magento.binding'
_description = 'Magento Sale Order'
_inherits = {'sale.order': 'odoo_id'}
odoo_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.

magento_order_line_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.

total_amount

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)
total_amount_tax

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)
magento_order_id
magento_parent_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.

storeview_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.

store_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.

export_state_change(allowed_states=None, comment=None, notify=None)[source]

Change state of a sales order on Magento

import_batch(backend, filters=None)[source]

Prepare the import of Sales Orders from Magento

_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.common.SaleOrder(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'sale.order'
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.

get_parent_id()[source]

Return the parent order.

For Magento sales orders, the magento parent order is stored in the binding, get it from there.

_magento_cancel()[source]

Cancel sales order on Magento

Do not export the other state changes, Magento handles them itself when it receives shipments and invoices.

write(vals)[source]
copy(default=None)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.common.MagentoSaleOrderLine(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.sale.order.line'
_inherit = 'magento.binding'
_description = 'Magento Sale Order Line'
_inherits = {'sale.order.line': 'odoo_id'}
magento_order_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.

odoo_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.

backend_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.

tax_rate

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)
notes

Basic string field, can be length-limited, usually displayed as a single-line string in clients.

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate – enable the translation of the field’s values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.
create(vals)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.common.SaleOrderLine(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'sale.order.line'
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.

create(vals)[source]
copy_data(default=None)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.common.SaleOrderAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.sale.order.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.sale.order'
_magento_model = 'sales_order'
_admin_path = '{model}/view/order_id/{id}'
_call(method, arguments)[source]
search(filters=None, from_date=None, to_date=None, magento_storeview_ids=None)[source]

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

Return type:list
read(id, attributes=None)[source]

Returns the information of a record

Return type:dict
get_parent(id)[source]
add_comment(id, status, comment=None, notify=False)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.importer.SaleOrderBatchImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.sale.order.batch.importer'
_inherit = 'magento.delayed.batch.importer'
_apply_on = 'magento.sale.order'
_import_record(external_id, job_options=None, **kwargs)[source]
run(filters=None)[source]

Run the synchronization

_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.importer.SaleImportRule(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.sale.import.rule'
_inherit = 'base.magento.connector'
_apply_on = 'magento.sale.order'
_usage = 'sale.import.rule'
_rule_always(record, method)[source]

Always import the order

_rule_never(record, method)[source]

Never import the order

_rule_authorized(record, method)[source]

Import the order only if payment has been authorized.

_rule_paid(record, method)[source]

Import the order only if it has received a payment

_rules = {'always': <function _rule_always>, 'never': <function _rule_never>, 'authorized': <function _rule_authorized>, 'paid': <function _rule_paid>}
_rule_global(record, method)[source]

Rule always executed, whichever is the selected rule

check(record)[source]

Check whether the current sale order should be imported or not. It will actually use the payment method configuration and see if the choosed rule is fullfilled.

Returns:True if the sale order should be imported
Return type:boolean
_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.importer.SaleOrderImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.sale.order.mapper'
_inherit = 'magento.import.mapper'
_apply_on = 'magento.sale.order'
direct = [('increment_id', 'external_id'), ('order_id', 'magento_order_id'), ('grand_total', 'total_amount'), ('tax_amount', 'total_amount_tax'), (<function modifier>, 'date_order'), ('store_id', 'storeview_id')]
children = [('items', 'magento_order_line_ids', 'magento.sale.order.line')]
_add_shipping_line(map_record, values)[source]
_add_cash_on_delivery_line(map_record, values)[source]
_add_gift_certificate_line(map_record, values)[source]
finalize(map_record, values)[source]
name(record)[source]
customer_id(record)[source]
payment(record)[source]
shipping_method(record)[source]
sales_team(record)[source]
project_id(record)[source]
fiscal_position(record)[source]
warehouse_id(record)[source]
backend_id(record)[source]
user_id(record)[source]

Do not assign to a Salesperson otherwise sales orders are hidden for the salespersons (access rules)

_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.importer.SaleOrderImporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.sale.order.importer'
_inherit = 'magento.importer'
_apply_on = 'magento.sale.order'
_must_skip()[source]

Hook called right after we read the data from the backend.

If the method returns a message giving a reason for the skipping, the import will be interrupted and the message recorded in the job (if the import is called directly by the job, not by dependencies).

If it returns None, the import will continue normally.

Returns:None | str | unicode
_clean_magento_items(resource)[source]

Method that clean the sale order line given by magento before importing it

This method has to stay here because it allow to customize the behavior of the sale order.

_merge_sub_items(product_type, top_item, child_items)[source]

Manage the sub items of the magento sale order lines. A top item contains one or many child_items. For some product types, we want to merge them in the main item, or keep them as order line.

This method has to stay because it allow to customize the behavior of the sale order according to the product type.

A list may be returned to add many items (ie to keep all child_items as items.

Parameters:
  • top_item – main item (bundle, configurable)
  • child_items – list of childs of the top item
Returns:

item or list of items

_import_customer_group(group_id)[source]
_before_import()[source]

Link the magento.sale.order to its parent orders.

When a Magento sales order is modified, it:
  • cancel the sales order
  • create a copy and link the canceled one as a parent

So we create the link to the parent sales orders. Note that we have to walk through all the chain of parent sales orders in the case of multiple editions / cancellations.

_create(data)[source]
_after_import(binding)[source]
_get_storeview(record)[source]

Return the tax inclusion setting for the appropriate storeview

_get_magento_data()[source]

Return the raw Magento data for self.external_id

_import_addresses()[source]
_check_special_fields()[source]
_create_data(map_record, **kwargs)[source]
_update_data(map_record, **kwargs)[source]
_import_dependencies()[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.importer.SaleOrderLineImportMapper(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.sale.order.line.mapper'
_inherit = 'magento.import.mapper'
_apply_on = 'magento.sale.order.line'
direct = [('qty_ordered', 'product_uom_qty'), ('qty_ordered', 'product_qty'), ('name', 'name'), ('item_id', 'external_id')]
discount_amount(record)[source]
product_id(record)[source]
product_options(record)[source]
price(record)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.sale_order.exporter.StateExporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.sale.state.exporter'
_inherit = 'base.exporter'
_usage = 'sale.state.exporter'
_apply_on = 'magento.sale.order'
ORDER_STATUS_MAPPING = {'waiting_date': 'holded', 'invoice_except': 'processing', 'draft': 'pending', 'shipping_except': 'processing', 'done': 'complete', 'cancel': 'canceled', 'progress': 'processing', 'manual': 'processing'}
run(binding, allowed_states=None, comment=None, notify=False)[source]

Change the status of the sales order on Magento.

It adds a comment on Magento with a status. Sales orders on Magento have a state and a status. The state is related to the sale workflow, and the status can be modified liberaly. We change only the status because Magento handle the state itself.

When a sales order is modified, if we used the sales_order.cancel API method, we would not be able to revert the cancellation. When we send cancel as a status change with a new comment, we are still able to change the status again and to create shipments and invoices because the state is still new or processing.

Parameters:
  • binding – the binding record of the sales order
  • allowed_states – list of Odoo states that are allowed for export. If empty, it will export any state.
  • comment – Comment to display on Magento for the state change
  • notify – When True, Magento will send an email with the comment
_module = 'connector_magento'

Stock Picking

class odoo.addons.connector_magento.models.stock_picking.common.MagentoStockPicking(pool, cr)[source]

Bases: odoo.models.Model

_name = 'magento.stock.picking'
_inherit = 'magento.binding'
_inherits = {'stock.picking': 'odoo_id'}
_description = 'Magento Delivery Order'
odoo_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.

magento_order_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.

picking_method
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.

export_tracking_number()[source]

Export the tracking number of a delivery order.

export_picking_done(with_tracking=True)[source]

Export a complete or partial delivery order.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.stock_picking.common.StockPicking(pool, cr)[source]

Bases: odoo.models.Model

_inherit = 'stock.picking'
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.

_module = 'connector_magento'
class odoo.addons.connector_magento.models.stock_picking.common.StockPickingAdapter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.stock.picking.adapter'
_inherit = 'magento.adapter'
_apply_on = 'magento.stock.picking'
_magento_model = 'sales_order_shipment'
_admin_path = 'sales_shipment/view/shipment_id/{id}'
_call(method, arguments)[source]
create(order_id, items, comment, email, include_comment)[source]

Create a record on the external system

add_tracking_number(external_id, carrier_code, tracking_title, tracking_number)[source]

Add new tracking number.

Parameters:
  • external_id – shipment increment id
  • carrier_code – code of the carrier on Magento
  • tracking_title – title displayed on Magento for the tracking
  • tracking_number – tracking number
get_carriers(external_id)[source]

Get the list of carrier codes allowed for the shipping.

Parameters:external_id – order increment id
Return type:list
_module = 'connector_magento'
class odoo.addons.connector_magento.models.stock_picking.common.MagentoBindingStockPickingListener(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.binding.stock.picking.listener'
_inherit = 'base.event.listener'
_apply_on = ['magento.stock.picking']
on_record_create(record, fields=None)[source]
_module = 'connector_magento'
class odoo.addons.connector_magento.models.stock_picking.common.MagentoStockPickingListener(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.stock.picking.listener'
_inherit = 'base.event.listener'
_apply_on = ['stock.picking']
on_tracking_number_added(record)[source]
on_picking_out_done(record, picking_method)[source]

Create a magento.stock.picking record. This record will then be exported to Magento.

Parameters:picking_method (str) – picking_method, can be ‘complete’ or ‘partial’
_module = 'connector_magento'
class odoo.addons.connector_magento.models.stock_picking.exporter.MagentoPickingExporter(work_context)[source]

Bases: odoo.addons.component.core.Component

_name = 'magento.stock.picking.exporter'
_inherit = 'magento.exporter'
_apply_on = ['magento.stock.picking']
_get_args(binding, lines_info=None)[source]
_get_lines_info(binding)[source]

Get the line to export to Magento. In case some lines doesn’t have a matching on Magento, we ignore them. This allow to add lines manually.

Parameters:binding – magento.stock.picking record
Returns:dict of {magento_product_id: quantity}
Return type:dict
_get_picking_mail_option(binding)[source]

Indicates if Magento has to send an email

Parameters:binding – magento.stock.picking record
Returns:value of send_picking_done_mail chosen on magento shop
Return type:boolean
run(binding)[source]

Export the picking to Magento

_module = 'connector_magento'