price_get_multi does not work for a list of pricelists

Bug #1011927 reported by Richard deMeester
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Low
OpenERP R&D Addons Team 2

Bug Description

In pricelist.py, in product, price_get calls price_get_multi

If a list of pricelist_ids is passed, the complete list returned is the same price multiple times!

The bug is that pricelist_version_ids is retrieved as a list, which does not at all link to pricelist_ids.
Then, in the loop (for pricelist_id in pricelist_ids) the cr.execute always uses pricelist_version_ids[0]!, not the pricelist_version_id for current pricelist.

The only way for this to work is to retrieve one pricelist at a time.

summary: - price_get_multi does not work for a list of pvices
+ price_get_multi does not work for a list of prices
summary: - price_get_multi does not work for a list of prices
+ price_get_multi does not work for a list of pricelists
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Richard,

I have completely checked your issue and It's working fine.

I have created two price list version one for May(public price) and second for June (with 50% discount on public price).
I try to create a SO for june and It will takes the perfect price list version (2nd). Also I have created a SO for May and It takes the 1st price list version. Additionally I printed the result on price_get_multi and got a only one pricelist_id and price.

I have attached the video for your more reference, which will clearly show the thing. So would you please check it and notify us where you faced the problem. Also please provide the proper use case on it.

Thanks and waiting for your reply!

Revision history for this message
Amit Parik (amit-parik) wrote :
Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Richard deMeester (richard-willowit) wrote :

Hello Amit,

The issue is not quite like you have tested. It works for Sales Orders because they request the current price for one pricelist only.

---------------

If I create two separate pricelists, call them "Selling Price" and "Alt Selling Price", and for the case of simplicity, each only has one pricelist version.

Now, assuming "Selling Price" is id "1" and "Alt Selling Price" is id "2", and the version ids are "11" and "12" respectively.

And for product id 1000, the selling prices are $1500 and $2500

If I create my own piece of code which calls:
      price_dict = self.pool.get('product.pricelist').price_get(cr, uid, [1], 1000, 1.0)
Then it will correctly return a dictionary:
      {'item_id' : 1000, 1: 1500}

Similarly,
      price_dict = self.pool.get('product.pricelist').price_get(cr, uid, [2], 1000, 1.0)
returns:
      {'item_id' : 1000, 2: 2500}

If my piece of code wants to get both selling prices, I try:
      price_dict = self.pool.get('product.pricelist').price_get(cr, uid, [1, 2], 1000, 1.0)
it returns:
      {'item_id' : 1000, 1: 1500, 2: 1500}

Price 2 is in fact 2500. Actually, whether it returns 1500 or 2500 is random, as it depends on the sequence of an unsorted list.

My use is that we need to get all the current prices for a product, and we could do it efficiently with one call to price_get, however, we now have to do it as a loop getting one price at a time.

As I said, the code in price_get_multi is wrong if more than one pricelist is passed.

pricelist_version_ids = self.pool.get('product.pricelist.version').search(cr, uid, [('pricelist_id','in',pricelist_ids) .......

And then uses pricelist_version_ids[0] for every pricelist in the loop.

I hope this makes sense.

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Richard,

Thanks for your quick response and nice explanation.. :).

I have tried the same scenario and faced the same problem. But I am not able to found that any real time situation where 2 price list are used for price calculation on same product. Well, price_get multi has a problem , It does not work for a list of pricelists.

So due to not found any real time scenario where these type of situation applicable. I am considering this as a "Low" importance .
Additionally I wonder that if I passed the list of ids like [2,1] I got the same result as [1,2] ( li.e {'item_id' : 1000, 1: 1500, 2: 1500} as per your example.)

If you have any real time scenario where 2 price list are used same time for same product then you can provide here.(May be it will help for raised importance)

Thanks again!

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Low
status: Incomplete → Confirmed
Revision history for this message
Richard deMeester (richard-willowit) wrote :

Hello Amit,

Thankyou. Yes, you are correct, I know of no current scenario which uses this. I use it to create a custom pricelist table, and it is obviously far more efficient to call the method once with a list than to loop through calling it once per pricelist.

Revision history for this message
Pablo (mrpavy) wrote :

Hellor Richard

I found a scenario, use a price list purchase, I create a pricelist to sales based on price list for purchase, there exists a bug, to sell I can not change the unit of measurement is the same value.

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.