Merge lp:~oddbloke/openobject-addons/623334 into lp:openobject-addons/5.0

Proposed by Dan Watkins
Status: Superseded
Proposed branch: lp:~oddbloke/openobject-addons/623334
Merge into: lp:openobject-addons/5.0
Diff against target: 181 lines (+46/-54)
1 file modified
account/report/third_party_ledger.py (+46/-54)
To merge this branch: bzr merge lp:~oddbloke/openobject-addons/623334
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+33517@code.launchpad.net

This proposal has been superseded by a proposal from 2010-08-24.

Description of the change

Fixes bug #623334, which involves Partner Account reports in the account module showing incorrect figures.

To post a comment you must log in.
2824. By Dan Watkins

Remove unused _sum_sdebit and _sum_scredit methods from partner_balance report.

2825. By Dan Watkins

Fix grand total display in the partner_balance report.

2826. By Dan Watkins

Fix individual lines in partner_balance report.

2827. By Dan Watkins

Fix aged_trial_balance report.

Unmerged revisions

2827. By Dan Watkins

Fix aged_trial_balance report.

2826. By Dan Watkins

Fix individual lines in partner_balance report.

2825. By Dan Watkins

Fix grand total display in the partner_balance report.

2824. By Dan Watkins

Remove unused _sum_sdebit and _sum_scredit methods from partner_balance report.

2823. By Dan Watkins

Fix third party ledger report.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/report/third_party_ledger.py'
2--- account/report/third_party_ledger.py 2010-05-27 10:59:00 +0000
3+++ account/report/third_party_ledger.py 2010-08-24 13:09:42 +0000
4@@ -256,12 +256,15 @@
5 if self.date_lst_string:
6 self.cr.execute(
7 "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \
8- "FROM account_move_line l " \
9+ "FROM (account_move_line l " \
10 "LEFT JOIN account_journal j " \
11- "ON (l.journal_id = j.id) " \
12+ "ON (l.journal_id = j.id)) " \
13+ "LEFT JOIN account_move m " \
14+ "ON (l.move_id = m.id) " \
15 "WHERE l.partner_id = %s " \
16 "AND l.account_id IN (" + self.account_ids + ") " \
17 "AND l.date IN (" + self.date_lst_string + ") " \
18+ "AND m.state = 'posted' " \
19 " " + RECONCILE_TAG + " "\
20 "ORDER BY l.id",
21 (partner.id,))
22@@ -274,6 +277,19 @@
23
24 return full_account
25
26+ def _get_line_sql(self):
27+ return "SELECT sum(line.%s) " \
28+ "FROM account_move_line line " \
29+ "LEFT JOIN account_move m ON (line.move_id = m.id) " \
30+ "WHERE line.account_id IN (" + self.account_ids + ") " \
31+ "AND m.state = 'posted' "
32+
33+ def _get_credit_sql(self):
34+ return self._get_line_sql() % ("credit", )
35+
36+ def _get_debit_sql(self):
37+ return self._get_line_sql() % ("debit", )
38+
39 def _sum_debit_partner(self, partner,data):
40
41 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
42@@ -283,13 +299,10 @@
43 else:
44 RECONCILE_TAG = "AND reconcile_id IS NULL"
45 if self.date_lst and data['form']['soldeinit'] :
46- self.cr.execute(
47- "SELECT sum(debit) " \
48- "FROM account_move_line " \
49- "WHERE partner_id = %s " \
50- "AND account_id IN (" + self.account_ids + ") " \
51- "AND reconcile_id IS NULL " \
52- "AND date < %s " ,
53+ self.cr.execute(self._get_debit_sql() +
54+ "AND line.partner_id = %s " \
55+ "AND line.reconcile_id IS NULL " \
56+ "AND line.date < %s ",
57 (partner.id, self.date_lst[0],))
58 contemp = self.cr.fetchone()
59 if contemp != None:
60@@ -298,13 +311,10 @@
61 result_tmp = result_tmp + 0.0
62
63 if self.date_lst_string:
64- self.cr.execute(
65- "SELECT sum(debit) " \
66- "FROM account_move_line " \
67- "WHERE partner_id = %s " \
68- "AND account_id IN (" + self.account_ids + ") " \
69+ self.cr.execute(self._get_debit_sql() +
70+ "AND line.partner_id = %s " \
71 " " + RECONCILE_TAG + " " \
72- "AND date IN (" + self.date_lst_string + ") " ,
73+ "AND line.date IN (" + self.date_lst_string + ") ",
74 (partner.id,))
75
76 contemp = self.cr.fetchone()
77@@ -322,13 +332,10 @@
78 else:
79 RECONCILE_TAG = "AND reconcile_id IS NULL"
80 if self.date_lst and data['form']['soldeinit'] :
81- self.cr.execute(
82- "SELECT sum(credit) " \
83- "FROM account_move_line " \
84- "WHERE partner_id=%s " \
85- "AND account_id IN (" + self.account_ids + ") " \
86- "AND reconcile_id IS NULL " \
87- "AND date < %s " ,
88+ self.cr.execute(self._get_credit_sql() +
89+ "AND line.partner_id=%s " \
90+ "AND line.reconcile_id IS NULL " \
91+ "AND line.date < %s ",
92 (partner.id,self.date_lst[0],))
93 contemp = self.cr.fetchone()
94 if contemp != None:
95@@ -337,13 +344,10 @@
96 result_tmp = result_tmp + 0.0
97
98 if self.date_lst_string:
99- self.cr.execute(
100- "SELECT sum(credit) " \
101- "FROM account_move_line " \
102- "WHERE partner_id=%s " \
103- "AND account_id IN (" + self.account_ids + ") " \
104+ self.cr.execute(self._get_credit_sql() +
105+ "AND line.partner_id=%s " \
106 " " + RECONCILE_TAG + " " \
107- "AND date IN (" + self.date_lst_string + ") " ,
108+ "AND line.date IN (" + self.date_lst_string + ") ",
109 (partner.id,))
110
111 contemp = self.cr.fetchone()
112@@ -363,13 +367,10 @@
113 else:
114 RECONCILE_TAG = "AND reconcile_id IS NULL"
115 if self.date_lst and data['form']['soldeinit'] :
116- self.cr.execute(
117- "SELECT sum(debit) " \
118- "FROM account_move_line " \
119- "WHERE partner_id IN (" + self.partner_ids + ") " \
120- "AND account_id IN (" + self.account_ids + ") " \
121- "AND reconcile_id IS NULL " \
122- "AND date < %s " ,
123+ self.cr.execute(self._get_debit_sql() +
124+ "AND line.partner_id IN (" + self.partner_ids + ") " \
125+ "AND line.reconcile_id IS NULL " \
126+ "AND line.date < %s ",
127 (self.date_lst[0],))
128 contemp = self.cr.fetchone()
129 if contemp != None:
130@@ -378,13 +379,10 @@
131 result_tmp = result_tmp + 0.0
132
133 if self.date_lst_string:
134- self.cr.execute(
135- "SELECT sum(debit) " \
136- "FROM account_move_line " \
137- "WHERE partner_id IN (" + self.partner_ids + ") " \
138- "AND account_id IN (" + self.account_ids + ") " \
139+ self.cr.execute(self._get_debit_sql() +
140+ "AND line.partner_id IN (" + self.partner_ids + ") " \
141 " " + RECONCILE_TAG + " " \
142- "AND date IN (" + self.date_lst_string + ") "
143+ "AND line.date IN (" + self.date_lst_string + ") ",
144 )
145
146 contemp = self.cr.fetchone()
147@@ -406,13 +404,10 @@
148 else:
149 RECONCILE_TAG = "AND reconcile_id IS NULL"
150 if self.date_lst and data['form']['soldeinit'] :
151- self.cr.execute(
152- "SELECT sum(credit) " \
153- "FROM account_move_line " \
154- "WHERE partner_id IN (" + self.partner_ids + ") " \
155- "AND account_id IN (" + self.account_ids + ") " \
156- "AND reconcile_id IS NULL " \
157- "AND date < %s " ,
158+ self.cr.execute(self._get_credit_sql() +
159+ "AND line.partner_id IN (" + self.partner_ids + ") " \
160+ "AND line.reconcile_id IS NULL " \
161+ "AND line.date < %s ",
162 (self.date_lst[0],))
163 contemp = self.cr.fetchone()
164 if contemp != None:
165@@ -421,13 +416,10 @@
166 result_tmp = result_tmp + 0.0
167
168 if self.date_lst_string:
169- self.cr.execute(
170- "SELECT sum(credit) " \
171- "FROM account_move_line " \
172- "WHERE partner_id IN (" + self.partner_ids + ") " \
173- "AND account_id IN (" + self.account_ids + ") " \
174+ self.cr.execute(self._get_credit_sql() +
175+ "AND line.partner_id IN (" + self.partner_ids + ") " \
176 " " + RECONCILE_TAG + " " \
177- "AND date IN (" + self.date_lst_string + ") "
178+ "AND line.date IN (" + self.date_lst_string + ") ",
179 )
180 contemp = self.cr.fetchone()
181 if contemp != None: