← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~hbrunn/ocb-addons/trunk_lp1237832 into lp:ocb-addons

 

Holger Brunn (Therp) has proposed merging lp:~hbrunn/ocb-addons/trunk_lp1237832 into lp:ocb-addons.

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1237832 in OpenERP Community Backports (Addons): "[6.1] [7.0] [trunk] [account_budget] doesn't recurse into analytic account's children"
  https://bugs.launchpad.net/ocb-addons/+bug/1237832

For more details, see:
https://code.launchpad.net/~hbrunn/ocb-addons/trunk_lp1237832/+merge/190317

Automatically derived from https://code.launchpad.net/~therp-nl/openobject-addons/trunk_lp1237832 for https://code.launchpad.net/~openerp/openobject-addons/trunk.
-- 
https://code.launchpad.net/~hbrunn/ocb-addons/trunk_lp1237832/+merge/190317
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~hbrunn/ocb-addons/trunk_lp1237832 into lp:ocb-addons.
=== modified file 'account_budget/account_budget.py'
--- account_budget/account_budget.py	2012-10-23 16:05:04 +0000
+++ account_budget/account_budget.py	2013-10-10 09:04:36 +0000
@@ -126,7 +126,21 @@
             if context.has_key('wizard_date_to'):
                 date_to = context['wizard_date_to']
             if line.analytic_account_id.id:
-                cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE account_id=%s AND (date "
+                cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE account_id in "
+                       """(with recursive account_analytic_account_hierarchy(id)
+                        as 
+                            (
+                                select id from account_analytic_account 
+                                    where id=%s
+                                union all
+                                select account_analytic_account.id from 
+                                    account_analytic_account 
+                                    join account_analytic_account_hierarchy
+                                    on account_analytic_account.parent_id=
+                                        account_analytic_account_hierarchy.id
+                            )"""
+                       "select id from account_analytic_account_hierarchy) "
+                       "AND (date "
                        "between to_date(%s,'yyyy-mm-dd') AND to_date(%s,'yyyy-mm-dd')) AND "
                        "general_account_id=ANY(%s)", (line.analytic_account_id.id, date_from, date_to,acc_ids,))
                 result = cr.fetchone()[0]


Follow ups