openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #05614
[Merge] lp:~camptocamp/margin-analysis/7.0-product_price_history-index-1301847 into lp:margin-analysis
Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/margin-analysis/7.0-product_price_history-index-1301847 into lp:margin-analysis.
Commit message:
Add index on the columns that are used in the SELECT everytime a price is fetched
Requested reviews:
Margin Analysis Core Editors (margin-analysis-core-editors)
Related bugs:
Bug #1301847 in Financial controlling and costing: "Index could be added on product_price_history"
https://bugs.launchpad.net/margin-analysis/+bug/1301847
For more details, see:
https://code.launchpad.net/~camptocamp/margin-analysis/7.0-product_price_history-index-1301847/+merge/214001
fix lp:1301847
Details on the bug report.
That also removes a TODO!
--
https://code.launchpad.net/~camptocamp/margin-analysis/7.0-product_price_history-index-1301847/+merge/214001
Your team Margin Analysis Core Editors is requested to review the proposed merge of lp:~camptocamp/margin-analysis/7.0-product_price_history-index-1301847 into lp:margin-analysis.
=== modified file 'product_price_history/product_price_history.py'
--- product_price_history/product_price_history.py 2014-02-04 10:46:08 +0000
+++ product_price_history/product_price_history.py 2014-04-03 11:22:08 +0000
@@ -33,10 +33,21 @@
class product_price_history(orm.Model):
- # TODO : Create good index for select
_name = 'product.price.history'
_order = 'datetime, company_id asc'
+ def _auto_init(self, cr, context=None):
+ res = super(product_price_history, self)._auto_init(cr,
+ context=context)
+ cr.execute("SELECT indexname "
+ "FROM pg_indexes "
+ "WHERE indexname = 'product_price_history_all_index'")
+ if not cr.fetchone():
+ cr.execute("CREATE INDEX product_price_history_all_index "
+ "ON product_price_history "
+ "(product_id, company_id, name, datetime)")
+ return res
+
_columns = {
'name': fields.char('Field name', size=32, required=True),
'company_id': fields.many2one('res.company', 'Company',
Follow ups