Issue in price computation when the product uom is different from the supplier uom

Bug #1220241 reported by Alexis de Lattre
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP R&D Addons Team 2

Bug Description

BUG SCENARIO in OpenERP 7.0
=========================

Here is the scenario to reproduce the bug in an up-to-date addons-70 (revno 9407) :

1. Create a new DB with demo data
2. install the "purchase" module
3. Add yourself to the group "Technical features", "Purchase pricelists" and "Manage multiple units of measures"
4. Create a new product will the following parameters :
  - name : "Perfume"
  - product type : stockable product
  - unit of measure (uom_id) : g
  - Purchase unit of Measure (uom_po_id) : kg
  On this product, add a supplier information :
  - Supplier : ASUSTeK
  - Minimal quantity : 5
  Then add the following quantities and prices :
  a) quantity : 5 - Price : 12.00
  b) quantity : 10 - Price : 9.00
  and save the product.
  On the saved product, if you open the supplier information for 'Asustek", you should see that the field "Supplier Unit of Measure" has been set to "kg".
5. Edit the "Default Purchase Pricelist", select its single version and then select its single pricelist item : on this pricelist item, set "Based on" to "Supplier prices on the product form".
6. Create a new purchase order for supplier "Asustek". Check that the Pricelist taken by the on_change is the "Default Purchase Pricelist" that you modified in the previous step. Add a new purchase order line and enter the product "Perfume". This on_change will bring the following values on the purchase order line :
- Quantity : 5
- Product unit of measure : kg
- Unit price : 0.00
=> that's the bug. The unit price should be 12.00.

PROPOSED SOLUTION
==================

In my DB (it is probably the same in yours) :
- "g" uom has ID 4
- "kg" uom has ID 3

In the code of the module "product", in the file product/pricelist.py, when you enter the function price_get_multi(self, cr, uid, pricelist_ids, products_by_qty_by_partner, context=None) of the product.pricelist object, you have :
products_by_qty_by_partner= [(50, 5, 5)] => the tuple is (product_id, qty, partner), so the qty is in kg
context= {'date': '2013-09-03', 'uom': 3} => the uom in context is "kg"

In the same function, after the line "elif res['base'] == -2" (which corresponds to "Based on" = "Supplier prices on the product form" in the pricelist item), the context is never read. OpenERP reads the uom_id on product.product (which is "g"), compare it to the uom on supplierinfo (which is "kg") and does some uom conversion, which leads to the bug.

I have made a small patch to propose a non-intrusive solution. I'm not sure it's the good one, but it works in my scenario. I have left the prints in my code to help the guys who will test my patch.

The best solution would probably be to add the uom as an argument of the function price_get_multi, to avoid misunderstandings on the uom of the qty. But this would be a much more intrusive patch...

Related branches

Revision history for this message
Alexis de Lattre (alexis-via) wrote :
Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Medium
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Mehul Mehta(OpenERP) (mehul.mehta-openerp) wrote :

Hello Alexis de Lattre,

Thanks for your patch.. i have tested ur patch it' working properly.
so it has been fixed on this branch https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1220241-mme with following :

    Revision ID: <email address hidden>
    Revision NO: 8894

thanks for your patch and contrbution.

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

Dear Alexis de Lattre,

I think the same problem also reproducible in 7.0, and your patch solves problem.
I will propose a branch for 7,0 Thanks for your fix.

Regards,
Rifakat

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

As of 2014-03-27, the bug is fixed in OpenERP 7 (tested with OCB-70)

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.