openerp-connector-community team mailing list archive
-
openerp-connector-community team
-
Mailing list archive
-
Message #00678
Doubt: Mapping fields over an non-customized magento backend version
Hi! I tell you,
I developed two independent modules that should work with the same
version of backend (magento1700), each module adds a mapping on
sale.order model as follows:
Module 1:
/@magento1700//
//class SaleOrderNotesImportMapper(SaleOrderImportMapper)://
// _model_name = 'magento.sale.order'//
//
// @mapping//
// def notes(self, record)://
// result = {}//
// notes = ''//
// set_intro = False//
// for line in record['items']://
// ifield = line['product_options']//
// if ifield://
// clean = php_load(ifield.encode('utf-8',
errors="ignore"))//
// options = clean.get('options', {})//
// options_label = []//
// begin = '[%s]' % (line['sku'],)//
// for key in options://
// if options[key].get('option_type', False) ==
'field'://
// options_label.append('%s %s: %s' % (begin,
options[key]['label'],//
//options[key]['value'],//
//))//
// begin = ','//
// if set_intro and options_label://
// notes = notes+'\n'//
// set_intro = True//
// notes = notes + "".join(options_label)//
// if notes://
// notes = _('Order_details:\n')+notes//
// result = {'note': notes}//
// return result/
Module 2:
/@magento1700
class SaleOrderCouponImportMapper(SaleOrderImportMapper):
_model_name = 'magento.sale.order'
def _add_coupon_discount_line(self, map_record, values):
_logger.error("Entramoas2")
record = map_record.source
description_line = False
coupon_code = record.get('coupon_code', False)
discount_description = record.get('discount_description', False)
if not coupon_code:
return values
line_builder = self.unit_for(MagentoCouponLineBuilder)
if discount_description:
description_line = discount_description
if coupon_code:
description_line = "%s(%s)" % (description_line,coupon_code, )
line_builder.coupon_code = description_line
line_builder.price_unit = 0.0
line = (0, 0, line_builder.get_line())
values['order_line'].append(line)
return values/
, when I try to import a Magento sale_order, i get this error:
/AssertionError: Several classes found for <class
'openerp.addons.magentoerpconnect.sale.SaleOrderImportMapper'> with
session <Session db_name: db_demo, uid: 1, context: {}>, model name:
magento.sale.order. Found: set([<class
'openerp.addons.magento_import_product_configurable_variants.models.sale.SaleOrderNotesImportMapper'>,
<class
'openerp.addons.magentoerpconnect_coupon_line_builder.models.sale.SaleOrderCouponImportMapper'>])//
/What is the correct way of two independent modules can add new fields
mapping to a non-customized version of backend?/
/I hope someone can help me with this issue ...
Follow ups