From c70e22c1a212d0f8af9671dbc135fb74a488fd7a Mon Sep 17 00:00:00 2001 From: mtr Date: Fri, 28 Jan 2011 17:14:50 +0530 Subject: [PATCH 1/4] [FIX] account: allows duplication of account lp bug: https://launchpad.net/bugs/708603 fixed bzr revid: mtr@mtr-20110128114450-998ho3olsdfno7yw --- addons/account/account.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 3abbe4cef2e..bd0839243a5 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -300,11 +300,13 @@ class account_account(osv.osv): brs.pop(0) for fn in field_names: sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) - for child in current.child_id: - if child.company_id.currency_id.id == current.company_id.currency_id.id: - sums[current.id][fn] += sums[child.id][fn] - else: - sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context) + if current.child_id: + for child in current.child_id: + if child.company_id.currency_id.id == current.company_id.currency_id.id: + if sums.get(child.id): + sums[current.id][fn] += sums[child.id][fn] + else: + sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context) res = {} null_result = dict((fn, 0.0) for fn in field_names) for id in ids: From 6127d931f3b19f62269943c094b59bec87c878f9 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 31 Jan 2011 12:06:45 +0530 Subject: [PATCH 2/4] [FIX] account: allows duplication of account lp bug: https://launchpad.net/bugs/708603 fixed bzr revid: mtr@mtr-20110131063645-pjwyyj3uv1jp40i1 --- addons/account/account.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index bd0839243a5..e9b0c9e7905 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -300,13 +300,12 @@ class account_account(osv.osv): brs.pop(0) for fn in field_names: sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) - if current.child_id: - for child in current.child_id: - if child.company_id.currency_id.id == current.company_id.currency_id.id: - if sums.get(child.id): - sums[current.id][fn] += sums[child.id][fn] - else: - sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context) + for child in current.child_id: + if child.company_id.currency_id.id == current.company_id.currency_id.id: + if sums.get(child.id, False): + sums[current.id][fn] += sums[child.id][fn] + else: + sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context) res = {} null_result = dict((fn, 0.0) for fn in field_names) for id in ids: From f1d38b5844dc5ad40935e0b2d16f246329d418ae Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 31 Jan 2011 13:07:05 +0530 Subject: [PATCH 3/4] [IMP] account:placed else condition inside 'if sums.get(child.id, False):' bzr revid: mtr@mtr-20110131073705-2m6d54pjia4y1506 --- addons/account/account.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index e9b0c9e7905..6d4fe4eb98f 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -304,8 +304,8 @@ class account_account(osv.osv): if child.company_id.currency_id.id == current.company_id.currency_id.id: if sums.get(child.id, False): sums[current.id][fn] += sums[child.id][fn] - else: - sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context) + else: + sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context) res = {} null_result = dict((fn, 0.0) for fn in field_names) for id in ids: From 6847838d4b9bc1505a2f894bf7934437eac1ce33 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 31 Jan 2011 13:32:07 +0530 Subject: [PATCH 4/4] [IMP] account:improved code for the account duplication bug bzr revid: mtr@mtr-20110131080207-hmsbxkmonkvdh3to --- addons/account/account.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 6d4fe4eb98f..8a2cbdb8451 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -301,8 +301,8 @@ class account_account(osv.osv): for fn in field_names: sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) for child in current.child_id: - if child.company_id.currency_id.id == current.company_id.currency_id.id: - if sums.get(child.id, False): + if sums.get(child.id, False): + if child.company_id.currency_id.id == current.company_id.currency_id.id: sums[current.id][fn] += sums[child.id][fn] else: sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context)