In improve_performance_on_try_assign.diff instantiate UOMs only once to actually improve performance.

This commit is contained in:
Albert Cervera i Areny 2019-08-22 15:17:56 +02:00
parent 6b970cb1e8
commit 2ac1ab3e07

View file

@ -1,7 +1,7 @@
diff -r 3d822d8cff23 move.py diff -r 3d822d8cff23 move.py
--- a/trytond/trytond/modules/stock/move.py Fri Jun 07 11:46:35 2019 +0200 --- 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 +++ b/trytond/trytond/modules/stock/move.py Fri Jun 07 11:50:52 2019 +0200
@@ -1389,11 +1389,26 @@ @@ -1389,11 +1389,27 @@
del quantities[key] del quantities[key]
# Round quantities # Round quantities
@ -23,11 +23,12 @@ diff -r 3d822d8cff23 move.py
+ +
+ default_uom = dict((x[0], x[1]) for x in + default_uom = dict((x[0], x[1]) for x in
+ cursor.fetchall()) + cursor.fetchall())
+ uoms = dict([(x, Uom(x)) for x in set(default_uom.values())])
+ +
for key, quantity in quantities.items(): for key, quantity in quantities.items():
location = key[0] location = key[0]
- uom = default_uom[id_getter(key)] - uom = default_uom[id_getter(key)]
+ uom = Uom(default_uom[id_getter(key)]) + uom = uoms[default_uom[id_getter(key)]]
quantities[key] = uom.round(float(quantity)) if quantity else 0.0 quantities[key] = uom.round(float(quantity)) if quantity else 0.0
return quantities return quantities