trytond-patches/stock_supply_production-performance-improvement.diff

31 lines
1.4 KiB
Diff

diff -r 4af84eb4246d product.py
--- a/trytond/trytond/modules/stock_supply_production/product.py Tue Feb 17 21:08:47 2015 +0100
+++ b/trytond/trytond/modules/stock_supply_production/product.py Wed Apr 15 17:57:32 2015 +0200
@@ -10,8 +10,10 @@
class Product:
__name__ = 'product.product'
- def get_supply_period(self):
- 'Return the supply period for the product'
+ @classmethod
+ def get_supply_periods(cls, products):
+ 'Return the supply period for each product'
pool = Pool()
Configuration = pool.get('production.configuration')
- return int(Configuration(1).supply_period or 0)
+ supply_period = int(Configuration(1).supply_period or 0)
+ return dict((p, supply_period) for p in products)
diff -r 4af84eb4246d production.py
--- a/trytond/trytond/modules/stock_supply_production/production.py Tue Feb 17 21:08:47 2015 +0100
+++ b/trytond/trytond/modules/stock_supply_production/production.py Wed Apr 15 17:57:32 2015 +0200
@@ -87,8 +87,8 @@
product_ids, with_childs=True)
# order product by supply period
- products_period = sorted((p.get_supply_period(), p)
- for p in sub_products)
+ products_period = sorted((sp, p) for p, sp
+ in Product.get_supply_periods(sub_products).iteritems())
for warehouse in warehouses:
quantities = dict((x, pbl.pop((warehouse.id, x), 0))