trytond-patches/fix_rounding_in_sync_invent...

50 lines
2.4 KiB
Diff

diff -r fdfe606e6b87 stock.py
--- a/trytond/trytond/modules/stock_lot/stock.py Thu Feb 19 00:04:21 2015 +0100
+++ b/trytond/trytond/modules/stock_lot/stock.py Mon Oct 05 11:56:24 2015 +0200
@@ -119,16 +119,19 @@
round=False)
if quantity < out_quantity:
outgoing_moves.extend(Move.copy([out_move], default={
- 'quantity': out_quantity - quantity,
+ 'quantity': Uom.round(
+ out_quantity - quantity,
+ out_move.uom.rounding),
}))
Move.write([out_move], {
- 'quantity': quantity,
+ 'quantity': Uom.round(
+ quantity, out_move.uom.rounding),
})
Move.write([out_move], {
'lot': move.lot.id,
})
quantity -= out_quantity
- assert quantity <= 0
+ assert quantity <= move.product.default_uom.rounding
class ShipmentOutReturn:
diff -r 519c1c1a1ca2 shipment.py
--- a/trytond/trytond/modules/stock/shipment.py Mon Oct 05 12:22:18 2015 +0200
+++ b/trytond/trytond/modules/stock/shipment.py Mon Oct 05 12:23:46 2015 +0200
@@ -1177,14 +1177,17 @@
continue
key = cls._sync_inventory_to_outgoing_grouping_key(move,
'outgoing')
- if outgoing_qty.get(key, 0.0) > 0.0:
+ if (outgoing_qty.get(key, 0.0)
+ > move.product.default_uom.rounding):
exc_qty = Uom.compute_qty(move.product.default_uom,
outgoing_qty[key], move.uom)
removed_qty = Uom.compute_qty(move.uom,
min(exc_qty, move.quantity), move.product.default_uom,
round=False)
Move.write([move], {
- 'quantity': max(0.0, move.quantity - exc_qty),
+ 'quantity': max(0.0, Uom.round(
+ move.quantity - exc_qty,
+ move.uom.rounding)),
})
outgoing_qty[key] -= removed_qty