← Back to team overview

openerp-india team mailing list archive

[Bug 1220241] Re: Issue in price computation when the product uom is different from the supplier uom

 

** Branch linked: lp:~openerp-dev/openobject-addons/trunk-
bug-1220241-mme

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1220241

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

Status in OpenERP Addons (modules):
  Fix Committed

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...

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1220241/+subscriptions


References