product uom conversion should use ceiling instead of rounding

Bug #1280463 reported by David Leach
28
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
OpenERP Publisher's Warranty Team

Bug Description

Warranty #M120914764-zcaevxmq

By default, OpenERP 7.0's product uom conversion rounds to specified precision using standard rounding.

This causes a problem in the following scenario:
1) Create a product with UoM single piece, and Purchase UoM 10-pack (bigger than reference, factor = 10, rounding = 1.0)
2) Create a make-to-order Sale Order for 4 of this product.
3) Confirm sale order, and view resulting Purchase Order.

We only want to buy the product in 10-packs, so the PO will be rounded to the nearest whole number of 4/10 = .4 = 0.

Obviously a PO for zero 10-packs will not fulfill the original sale order.

The solution would be as simple as modifying product.uom's _compute_qty_obj() function to use math.ceil() instead of round().

Tags: maintenance

Related branches

Revision history for this message
David Leach (david-leach) wrote :
Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

We agree with your analysis, we should round up when converting unit of measures.

We have created and merged a fix for this in addons 7.0

revno: 9868 [merge]
revision-id: <email address hidden>

Changed in openobject-addons:
importance: Undecided → Medium
status: New → Fix Released
Revision history for this message
Open Net Sàrl (openerp-open-net) wrote : Re: [Bug 1280463] Re: product uom conversion should use ceiling instead of rounding

Hello,

I tested, it is working now

Cordiales salutations

Eberhard J-A
Directeur
Certified OpenERP Functional Specialist

Open Net Sàrl
www.open-net.ch
59, Rue de l'industrie
1030 Bussigny
T: +41 (21) 701 42 45
Autoroute A1, Sortie "Crissier / Bussigny"
Bus TL 17, arrêt Croix-de-Plan

----- Mail original -----
> De: "Martin Trigaux (OpenERP)" <email address hidden>
> À: <email address hidden>
> Envoyé: Vendredi 7 Mars 2014 16:41:30
> Objet: [Bug 1280463] Re: product uom conversion should use ceiling instead of rounding
>
> ** Changed in: openobject-addons
> Importance: Undecided => Medium
>
> ** Changed in: openobject-addons
> Status: New => Fix Released
>
> --
> You received this bug notification because you are subscribed to
> OpenERP
> Addons.
> https://bugs.launchpad.net/bugs/1280463
>
> Title:
> product uom conversion should use ceiling instead of rounding
>
> Status in OpenERP Addons (modules):
> Fix Released
>
> Bug description:
> Warranty #M120914764-zcaevxmq
>
> By default, OpenERP 7.0's product uom conversion rounds to
> specified
> precision using standard rounding.
>
> This causes a problem in the following scenario:
> 1) Create a product with UoM single piece, and Purchase UoM 10-pack
> (bigger than reference, factor = 10, rounding = 1.0)
> 2) Create a make-to-order Sale Order for 4 of this product.
> 3) Confirm sale order, and view resulting Purchase Order.
>
> We only want to buy the product in 10-packs, so the PO will be
> rounded
> to the nearest whole number of 4/10 = .4 = 0.
>
> Obviously a PO for zero 10-packs will not fulfill the original sale
> order.
>
> The solution would be as simple as modifying product.uom's
> _compute_qty_obj() function to use math.ceil() instead of round().
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-addons/+bug/1280463/+subscriptions
>

Revision history for this message
Wolfgang Taferner (TaPo-IT) (w.taferner) wrote :

Hi Martin and Oliver,
This fix actually caused another issue on /addons/stock/wizard/stock_partial_picking.py:180

Not always but for example with the quantity 16.390,990 kg and therefore blocks the flow even worse...

It computes from 16.390,990 to 16.390,991 which is completly wrong...

179: #Compute the quantity for respective wizard_line in the line uom (this jsut do the rounding if necessary)
180: qty_in_line_uom = uom_obj._compute_qty(cr, uid, line_uom.id, wizard_line.quantity, line_uom.id)
181:
182: if line_uom.factor and line_uom.factor <> 0:
183: if float_compare(qty_in_line_uom, wizard_line.quantity, precision_rounding=line_uom.rounding) != 0:
184: raise osv.except_osv(_('Warning!'), _('The unit of measure rounding does not allow you to ship "%s %s", only rounding of "%s %s" is accepted by the Unit of Measure.')

Please elaborate further...if you need another OPW, just drop me a note.

All the best,
Wolfgang

Revision history for this message
Wolfgang Taferner (TaPo-IT) (w.taferner) wrote :

Ok, I have now the use case to reproduce in runbot...

First you need to set the rounding of kilogram to 0,001

Then you create a sale order and add a sale order line with a product with kg and enter only the amount of 16.390,99 without the trailing zero.

Afterwards you confirm the sale order and try to deliver the goods. Due to ceiling and the rounding you will run into a showblocker.

You will not be able to deliver although everything is correct (The unit of measure rounding does....)

As stated above the input float in combination with ceiling does compute the wrong result.

Solution might be to solve the input problem b/c it works if I enter 16.390,990 but it does not by entering 16.390.99!!!

Olivier and Martin, please take a look b/c this is a major issue with OpenERP itself which needs to be solved (I don't have the time to convince the whole support/bug chain before)

I actually spotted this kind of input problem in trunk with the new trunk-wms as well...

Feel free to contact me if you can not reproduce this as it was tricky for me to identify too.

Revision history for this message
Mohammad Alhashash (alhashash) wrote :

I opened an issue on github for the bug introduced by the fix as decribed by Wolfgang. Check it at https://github.com/odoo/odoo/issues/1125

Also, I made a pull request for a fix: https://github.com/odoo/odoo/pull/1126

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.