price_multi_get() is comparing pricelist_ids to pricelist_version_ids
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Fix Released
|
Low
|
OpenERP R&D Addons Team 2 |
Bug Description
Version 6 trunk
server revno: 3137
addons revno: 4033
I have posted a question a few days ago:
https:/
I think this is a real bug and deserves to be posted here.
product/
Prior to this version, the pricelist_ids argument to price_get() was translated to pricelist_
In revno:3566 where "ids" are priclist_ids passed on "price_get()":
153 for id in ids:
154 cr.execute('SELECT * ' \
155 'FROM product_
156 'WHERE pricelist_id = %s AND active=True ' \
157 'AND (date_start IS NULL OR date_start <= %s) ' \
158 'AND (date_end IS NULL OR date_end >= %s) ' \
159 'ORDER BY id LIMIT 1', (id, date, date))
160 plversion = cr.dictfetchone()
......
190 cr.execute(
191 'SELECT i.*, pl.currency_id '
192 'FROM product_
193 'product_
194 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
195 'AND (product_id IS NULL OR product_id = %s) '
196 'AND (' + categ_where + ' OR (categ_id IS NULL)) '
197 'AND price_version_id = %s '
198 'AND (min_quantity IS NULL OR min_quantity <= %s) '
199 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
200 'ORDER BY sequence',
201 (tmpl_id, prod_id, plversion['id'], qty))
202 res1 = cr.dictfetchall()
Above code looks okay:
1. ids are translated to pricelist versions in "plversion"
2. line 197 matches price_version_id to plversion['id']
Current version revno:4033 (since revno:3719):
167 if pricelist_ids:
168 pricelist_
169 else:
170 # all pricelists:
171 pricelist_
*******
Above code stores "pricelist_ids" and "product_
*******
172
173 pricelist_
174
175 plversions_
176 ('pricelist_id', 'in', pricelist_
177 '|',
178 ('date_start', '=', False),
179 ('date_start', '<=', date),
180 '|',
181 ('date_end', '=', False),
182 ('date_end', '>=', date),
183 ]
184
185 plversion_ids = product_
*******
line 176 is matching "pricelist_id" to pricelist_
*******
202 for product_id, qty, partner in products_
203 for pricelist_id in pricelist_
204 price = False
205
206 tmpl_id = products_
207
208 categ_id = products_
209 categ_ids = _create_
210 if categ_ids:
211 categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
212 else:
213 categ_where = '(categ_id IS NULL)'
214
215 cr.execute(
216 'SELECT i.*, pl.currency_id '
217 'FROM product_
218 'product_
219 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
220 'AND (product_id IS NULL OR product_id = %s) '
221 'AND (' + categ_where + ' OR (categ_id IS NULL)) '
222 'AND price_version_id = %s '
223 'AND (min_quantity IS NULL OR min_quantity <= %s) '
224 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
225 'ORDER BY sequence',
226 (tmpl_id, product_id, pricelist_id, qty))
227 res1 = cr.dictfetchall()
*******
line 222 is matching "price_version_id" against "pricelist_id" from line 203
"pricelist_id" is derived from "pricelist_
*******
My question at https:/
was based on data that resulted in the above sql trying to match object ids of two different object (priclist_ids and pricelist_
To me it looks like the code is broken...but my head hurts looking at it.
Related branches
- OpenERP Core Team: Pending requested
-
Diff: 54 lines (+9/-3)2 files modifiedmrp_operations/mrp_operations.py (+8/-2)
product/product.py (+1/-1)
Changed in openobject-addons: | |
assignee: | nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2) |
importance: | Undecided → Low |
status: | Incomplete → Confirmed |
Changed in openobject-addons: | |
status: | Fix Committed → Fix Released |
Changed in openobject-addons: | |
milestone: | none → 6.0 |
Hello Snook,
Would you please elaborate more with proper examples because I did not get the exact idea from piece of code which you have specified in the bug specification.
Thanks.