mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
35 lines
1.4 KiB
Diff
35 lines
1.4 KiB
Diff
diff -r 3d822d8cff23 move.py
|
|
--- a/trytond/trytond/modules/stock/move.py Fri Jun 07 11:46:35 2019 +0200
|
|
+++ b/trytond/trytond/modules/stock/move.py Fri Jun 07 11:50:52 2019 +0200
|
|
@@ -1389,11 +1389,27 @@
|
|
del quantities[key]
|
|
|
|
# Round quantities
|
|
- default_uom = dict((p.id, p.default_uom) for p in
|
|
- Model.browse(list(ids)))
|
|
+ Uom = Pool().get('product.uom')
|
|
+ ttemplate = Template.__table__()
|
|
+ table = Model.__table__()
|
|
+ cursor = Transaction().connection.cursor()
|
|
+ if Model == Template:
|
|
+ cursor.execute(*ttemplate.select(ttemplate.id,
|
|
+ ttemplate.default_uom,
|
|
+ where=reduce_ids(ttemplate.id, ids)))
|
|
+ else:
|
|
+ cursor.execute(*ttemplate.join(table,
|
|
+ condition=table.template == ttemplate.id).select(
|
|
+ table.id, ttemplate.default_uom,
|
|
+ where=reduce_ids(table.id, ids)))
|
|
+
|
|
+ default_uom = dict((x[0], x[1]) for x in
|
|
+ cursor.fetchall())
|
|
+ uoms = dict([(x, Uom(x)) for x in set(default_uom.values())])
|
|
+
|
|
for key, quantity in quantities.items():
|
|
location = key[0]
|
|
- uom = default_uom[id_getter(key)]
|
|
+ uom = uoms[default_uom[id_getter(key)]]
|
|
quantities[key] = uom.round(float(quantity)) if quantity else 0.0
|
|
|
|
return quantities
|