add improve_performance_on_try_assign.diff

This commit is contained in:
?ngel ?lvarez 2018-07-24 17:01:24 +02:00
parent fc7e78b526
commit 6daec031bd
2 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,43 @@
diff -r 3239605d105d move.py
--- a/trytond/trytond/modules/stock/move.py Mon May 21 20:17:34 2018 +0200
+++ b/trytond/trytond/modules/stock/move.py Fri Jul 20 12:16:25 2018 +0200
@@ -850,6 +850,7 @@
])
else:
locations = list(set((m.from_location for m in moves)))
+
location_ids = [l.id for l in locations]
product_ids = list(set((m.product.id for m in moves)))
stock_date_end = Date.today()
@@ -1446,12 +1447,27 @@
if location not in location_ids:
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())
+
for key, quantity in quantities.iteritems():
location = key[0]
- uom = default_uom[id_getter(key)]
+ uom = Uom(default_uom[id_getter(key)])
quantities[key] = uom.round(quantity)
return quantities

1
series
View file

@ -18,3 +18,4 @@ stock_consignment_create_invoice_lines_on_move_done.diff # [stock_consignment] T
issue240_631.diff # [stock_lot] stock_by_locations get all locations with that lot.
issue10467.diff # stock_lot: add lot to grouping if lot it's required on product
purchase_request.diff # purchase_request: as shippment_date it's not required we need to ensure operation could be done
improve_performance_on_try_assign.diff # [stock] change browse of product to get default_uom to pysql