Comment 0 for bug 1188629

Revision history for this message
Yann Papouin (yann-papouin) wrote :

The price_surcharge is not linked to product uom. It's a mistake or a design choice ?

eg: ProductA with an UOM = PCE with a price of 10.0
If in the pricelist, you defines a surcharge of 2.0

When the price is computed you will have:
ProductA with Quantity 1.0 x PCE = 10.0 + 2.0 = 12.0
ProductA with Quantity 1.0 x 10PCE = 100.0 + 2.0 = 102.0
ProductA with Quantity 1.0 x 50PCE = 500.0 + 2.0 = 502.0

That's not correct, you should have:
ProductA with Quantity 1.0 x PCE = 10.0 + 2.0 = 12.0
ProductA with Quantity 1.0 x 10PCE = 100.0 + 20.0 = 120.0
ProductA with Quantity 1.0 x 50PCE = 500.0 + 100.0 = 600.0

Fix proposal:
=========================
in addons/product/pricelist.py

REPLACE:
-----------------------------------
if price is not False:
      price_limit = price
      price = price * (1.0+(res['price_discount'] or 0.0))
      price = rounding(price, res['price_round']) #TOFIX: rounding with tools.float_rouding
      price += (res['price_surcharge'] or 0.0)
      if res['price_min_margin']:
          price = max(price, price_limit+res['price_min_margin'])
      if res['price_max_margin']:
          price = min(price, price_limit+res['price_max_margin'])
      break

WITH:
-----------------------------------
if price is not False:
    surcharge = res['price_surcharge'] or 0.0)
    if 'uom' in context:
        product = products_dict[product_id]
        uom = product.uom_po_id or product.uos_id
        surcharge = product_uom_obj._compute_price(cr, uid, uom.id, surcharge, context['uom'])

    price_limit = price
    price = price * (1.0+(res['price_discount'] or 0.0))
    price = rounding(price, res['price_round']) #TOFIX: rounding with tools.float_rouding
    price += surcharge

    if res['price_min_margin']:
        price = max(price, price_limit+res['price_min_margin'])
    if res['price_max_margin']:
        price = min(price, price_limit+res['price_max_margin'])
    break