2012-06-22 14:37:57 |
Equipo OPENTIA (http://www.opentia.com) |
description |
This is the method in product_product(product_mag_osv):
def action_before_exporting_grouped_product(self, cr, uid, id, external_referential_ids=None, defaults=None, context=None):
logger = logging.getLogger('ext synchro')
if context.get('mrp_is_installed', False):
bom_ids = self.read(cr, uid, id, ['bom_ids'])['bom_ids']
if len(bom_ids): # it has or is part of a BoM
cr.execute("SELECT product_id, product_qty FROM mrp_bom WHERE bom_id = %s", (bom_ids[0],)) #FIXME What if there is more than a materials list?
results = cr.dictfetchall()
child_ids = []
quantities = {}
for row in results:
child_ids.append(row['product_id'])
quantities.update({row['product_id']: row['product_qty']})
if child_ids: #it is an assembly and it contains the products child_ids:
self.ext_export(cr, uid, child_ids, external_referential_ids, defaults, context) #so we export them
else:
return False
else:
logger.error("OpenERP 'grouped' products will export to Magento as 'grouped products' only if they have a BOM and if the 'mrp' BOM module is installed")
return quantities, child_ids
There are inconsistencies in this method:
- if NOT mrp_is_installed, we don't initialize 'quantities' and 'child_ids' variables
- if mrp_is_installed but there are no BOMs, we return False
The first one is an error itself, because the method uses those variables at the end of the execution, within the 'return' statement
The second one results in a "TypeError: 'bool' object is not iterable", because the code that uses it does not expect a False:
quantities, child_ids = self.action_before_exporting_grouped_product(cr, uid, id, external_referential_ids, defaults, context)
Attached is a patch that mitigates the stop in the execution. Don't know if it is valid in terms of this module logic though.
Greetings, |
This report is for
========================
Openerp6.1-legacy-module
========================
This is the method in product_product(product_mag_osv):
def action_before_exporting_grouped_product(self, cr, uid, id, external_referential_ids=None, defaults=None, context=None):
logger = logging.getLogger('ext synchro')
if context.get('mrp_is_installed', False):
bom_ids = self.read(cr, uid, id, ['bom_ids'])['bom_ids']
if len(bom_ids): # it has or is part of a BoM
cr.execute("SELECT product_id, product_qty FROM mrp_bom WHERE bom_id = %s", (bom_ids[0],)) #FIXME What if there is more than a materials list?
results = cr.dictfetchall()
child_ids = []
quantities = {}
for row in results:
child_ids.append(row['product_id'])
quantities.update({row['product_id']: row['product_qty']})
if child_ids: #it is an assembly and it contains the products child_ids:
self.ext_export(cr, uid, child_ids, external_referential_ids, defaults, context) #so we export them
else:
return False
else:
logger.error("OpenERP 'grouped' products will export to Magento as 'grouped products' only if they have a BOM and if the 'mrp' BOM module is installed")
return quantities, child_ids
There are inconsistencies in this method:
- if NOT mrp_is_installed, we don't initialize 'quantities' and 'child_ids' variables
- if mrp_is_installed but there are no BOMs, we return False
The first one is an error itself, because the method uses those variables at the end of the execution, within the 'return' statement
The second one results in a "TypeError: 'bool' object is not iterable", because the code that uses it does not expect a False:
quantities, child_ids = self.action_before_exporting_grouped_product(cr, uid, id, external_referential_ids, defaults, context)
Attached is a patch that mitigates the stop in the execution. Don't know if it is valid in terms of this module logic though.
Greetings, |
|