[6.1-legacy] Export Catalog broken if product_type == 'grouped'

Bug #1016549 reported by Equipo OPENTIA (http://www.opentia.com)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magento OpenERP Connector
Triaged
Undecided
Guewen Baconnier @ Camptocamp

Bug Description

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,

Revision history for this message
Equipo OPENTIA (http://www.opentia.com) (opentia) wrote :
description: updated
summary: - Export Catalog broken if product_type == 'grouped'
+ [6.1-legacy] Export Catalog broken if product_type == 'grouped'
tags: added: 6.1-legacy
Changed in magentoerpconnect:
assignee: nobody → Guewen Baconnier @ Camptocamp (gbaconnier-c2c)
Changed in magentoerpconnect:
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.