[6.0.3] Incorrect Variable naming in product/pricelist.py - price_get_multi

Bug #847605 reported by Graeme Gellatly
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 2

Bug Description

Hi this bit of code, while it doesn't cause a bug is really confusing. Bear in mind this is in an awful function of 98 statements and 54 local variables, so it is hard enough to understand already.

The variable pricelist_version_ids is unnecessary, but even if it were necessary, it should correctly be called pricelist_ids. In fact the whole first block of code could just be reduced to an - if not pricelist_ids:
pricelist_ids = self.pool.get('product.pricelist').search(cr, uid, [], context=context).

next we have plversions_search_args. I get why it has been seperated out, but it is a bit unnecessary as well. It is only used one time and only on the next line so why create the variable.

Now there is plversions_ids, which should more correctly be called pricelist_version_ids (but that was already taken unnecessarily as per above) but I suppose it is still explanatory.

       if pricelist_ids:
            pricelist_version_ids = pricelist_ids
        else:
            # all pricelists:
            pricelist_version_ids = self.pool.get('product.pricelist').search(cr, uid, [], context=context)

        pricelist_version_ids = list(set(pricelist_version_ids))
        plversions_search_args = [
            ('pricelist_id', 'in', pricelist_version_ids),
            '|',
            ('date_start', '=', False),
            ('date_start', '<=', date),
            '|',
            ('date_end', '=', False),
            ('date_end', '>=', date),
        ]

        plversion_ids = product_pricelist_version_obj.search(cr, uid, plversions_search_args)

Related branches

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Rohan Nayani(Open ERP) (ron-tinyerp) wrote :

Hello ,

Thanks for Reporting.
It has been fixed in lp:~openerp-dev/openobject-addons/trunk-bug-847605-ron
revision-id: <email address hidden>
Revision num:4962.

It will be available in trunk soon.

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
qdp (OpenERP) (qdp) wrote :

fix landed in trunk in revision 5335

Thanks for the contribution

Changed in openobject-addons:
status: Fix Committed → Fix Released
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.