Prices are not correctly returned by price_get_multi method from product\pricelist.py

Bug #715682 reported by OpenERP Romania
26
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP R&D Addons Team 2

Bug Description

The problem is on the line: (tmpl_id, product_id, plversion_ids[0], qty))

The code returns for all the pricelist versions the price from the first pricelist version.

To correct the error you must modify the line like this:(tmpl_id, product_id, pricelist_id, qty))

Tags: pricelist
description: updated
affects: openobject-server → openobject-addons
Revision history for this message
snook (snook) wrote :

Just a thought.

Pricing code has been modified significantly from V5 to V6.

As it is such a critical and core module to OpenERP, I sincerely recommend that it be given a serious review but some "smart" developers/analysts.

Pricing is bound to quantity, partners, UOM, UOS resulting in a complex mix that needs to be uniform across OpenERP modules.

Also a significant test suite should exist to map all the above usage. (I dont think there is any code testing UOM or quantity pricing)

Hope this reaches someone who cares ;)

Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

I have checked the issue and it seems right with the current code as we find the unique value from the list which we have passed in the query of price_get_multi method. If you are check with it again by putting the product_id instead both will have the same outcome.

If you want to check this simply print the both the variables, it will give you the same values. Hope you will agree with this and for now I am closing this bug.

Thanks for your participation.

Changed in openobject-addons:
status: New → Invalid
Revision history for this message
Andreas Brueckl (andreas-brueckl) wrote :

Hello,

For my opinion there is an error in price_get_multi. If there are passed more than 1 pricelists always the price of the first pricelist-version is returned. This is because of plversion_ids[0].

Here is my suggested patch:
--- pricelist.py.bak 2011-05-03 15:53:55.213832201 +0200
+++ pricelist.py 2011-05-11 15:26:47.948970453 +0200
@@ -184,6 +184,11 @@
             msg = "At least one pricelist has no active version !\nPlease create or activate one."
             raise osv.except_osv(_('Warning !'), _(msg))

+ versions = product_pricelist_version_obj.read(cr, uid, plversion_ids, ['pricelist_id','id'])
+ plversions_dict = {}
+ for v in versions:
+ plversions_dict[v['pricelist_id'][0]] = v['id']
+
         # product.product:
         product_ids = [i[0] for i in products_by_qty_by_partner]
         #products = dict([(item['id'], item) for item in product_obj.read(cr, uid, product_ids, ['categ_id', 'product_tmpl_id', 'uos_id', 'uom_id'])])
@@ -220,7 +225,7 @@
                         'AND (min_quantity IS NULL OR min_quantity <= %s) '
                         'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
                     'ORDER BY sequence',
- (tmpl_id, product_id, plversion_ids[0], qty))
+ (tmpl_id, product_id, plversions_dict[pricelist_id], qty))
                 res1 = cr.dictfetchall()
                 uom_price_already_computed = False
                 for res in res1:

Changed in openobject-addons:
status: Invalid → Confirmed
Revision history for this message
Andreas Brueckl (andreas-brueckl) wrote :

This patches the problem with multiple pricelists.

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Wishlist
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.