Issue in price computation when the product uom is different from the supplier uom
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/
products_
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
- OpenERP Core Team: Pending requested
-
Diff: 39 lines (+9/-6)1 file modifiedproduct/pricelist.py (+9/-6)
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 |
Changed in openobject-addons: | |
status: | In Progress → Fix Committed |
Hello Alexis de Lattre,
Thanks for your patch.. i have tested ur patch it' working properly. /code.launchpad .net/~openerp- dev/openobject- addons/ trunk-bug- 1220241- mme with following :
so it has been fixed on this branch https:/
Revision ID: <email address hidden>
Revision NO: 8894
thanks for your patch and contrbution.