Merge lp:~therp-nl/openobject-addons/6.1-ronald@therp.nl_fix_lp1015995 into lp:openobject-addons/6.1

Proposed by Ronald Portier (Therp)
Status: Work in progress
Proposed branch: lp:~therp-nl/openobject-addons/6.1-ronald@therp.nl_fix_lp1015995
Merge into: lp:openobject-addons/6.1
Diff against target: 60 lines (+18/-33)
1 file modified
account_analytic_analysis/account_analytic_analysis.py (+18/-33)
To merge this branch: bzr merge lp:~therp-nl/openobject-addons/6.1-ronald@therp.nl_fix_lp1015995
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+111813@code.launchpad.net

Description of the change

Replace view definition for account_analytic_analysis_summary_user to prevent cpu meltdown and postgres crash.

New view definition does NOT include users, or accounts, without amount, but they are filtered out on use anyway.

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_analytic_analysis/account_analytic_analysis.py'
--- account_analytic_analysis/account_analytic_analysis.py 2012-01-31 13:36:57 +0000
+++ account_analytic_analysis/account_analytic_analysis.py 2012-06-25 10:37:26 +0000
@@ -419,39 +419,24 @@
419419
420 def init(self, cr):420 def init(self, cr):
421 tools.sql.drop_view_if_exists(cr, 'account_analytic_analysis_summary_user')421 tools.sql.drop_view_if_exists(cr, 'account_analytic_analysis_summary_user')
422 cr.execute('CREATE OR REPLACE VIEW account_analytic_analysis_summary_user AS (' \422 cr.execute('''CREATE OR REPLACE VIEW account_analytic_analysis_summary_user AS (
423 'SELECT ' \423 with mu as
424 '(u.account_id * u.max_user) + u."user" AS id, ' \424 (select max(id) as max_user from res_users)
425 'u.account_id AS account_id, ' \425 , lu AS
426 'u."user" AS "user", ' \426 (SELECT
427 'COALESCE(SUM(l.unit_amount), 0.0) AS unit_amount ' \427 l.account_id AS account_id,
428 'FROM ' \428 coalesce(l.user_id, 0) AS user_id,
429 '(SELECT ' \429 SUM(l.unit_amount) AS unit_amount
430 'a.id AS account_id, ' \430 FROM account_analytic_line AS l,
431 'u1.id AS "user", ' \431 account_analytic_journal AS j
432 'MAX(u2.id) AS max_user ' \432 WHERE (j.type = 'general' ) and (j.id=l.journal_id)
433 'FROM ' \433 GROUP BY l.account_id, l.user_id
434 'res_users AS u1, ' \434 )
435 'res_users AS u2, ' \435 select (lu.account_id * mu.max_user) + lu.user_id as id,
436 'account_analytic_account AS a ' \436 lu.account_id as account_id,
437 'GROUP BY u1.id, a.id ' \437 lu.user_id as "user",
438 ') AS u ' \438 unit_amount
439 'LEFT JOIN ' \439 from lu, mu)''')
440 '(SELECT ' \
441 'l.account_id AS account_id, ' \
442 'l.user_id AS "user", ' \
443 'SUM(l.unit_amount) AS unit_amount ' \
444 'FROM account_analytic_line AS l, ' \
445 'account_analytic_journal AS j ' \
446 'WHERE (j.type = \'general\') and (j.id=l.journal_id) ' \
447 'GROUP BY l.account_id, l.user_id ' \
448 ') AS l '
449 'ON (' \
450 'u.account_id = l.account_id ' \
451 'AND u."user" = l."user"' \
452 ') ' \
453 'GROUP BY u."user", u.account_id, u.max_user' \
454 ')')
455440
456account_analytic_account_summary_user()441account_analytic_account_summary_user()
457442