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+33518@code.launchpad.net

This proposal supersedes a proposal from 2010-08-24.

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

Description of the change

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

Essentially, we are joining with the moves that the move lines are part of, to ensure that they aren't in Draft status. I've then consolidated the shared SQL strings into _get_line_sql, _get_credit_sql and _get_debit_sql.

To post a comment you must log in.
Revision history for this message
Dan Watkins (oddbloke) wrote :

So this doesn't fully fix bug #623334, that was a mis-type. It does, however, fix the Partner Ledger report problem.

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
=== modified file 'account/report/third_party_ledger.py'
--- account/report/third_party_ledger.py 2010-05-27 10:59:00 +0000
+++ account/report/third_party_ledger.py 2010-08-24 13:10:20 +0000
@@ -256,12 +256,15 @@
256 if self.date_lst_string:256 if self.date_lst_string:
257 self.cr.execute(257 self.cr.execute(
258 "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \258 "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \
259 "FROM account_move_line l " \259 "FROM (account_move_line l " \
260 "LEFT JOIN account_journal j " \260 "LEFT JOIN account_journal j " \
261 "ON (l.journal_id = j.id) " \261 "ON (l.journal_id = j.id)) " \
262 "LEFT JOIN account_move m " \
263 "ON (l.move_id = m.id) " \
262 "WHERE l.partner_id = %s " \264 "WHERE l.partner_id = %s " \
263 "AND l.account_id IN (" + self.account_ids + ") " \265 "AND l.account_id IN (" + self.account_ids + ") " \
264 "AND l.date IN (" + self.date_lst_string + ") " \266 "AND l.date IN (" + self.date_lst_string + ") " \
267 "AND m.state = 'posted' " \
265 " " + RECONCILE_TAG + " "\268 " " + RECONCILE_TAG + " "\
266 "ORDER BY l.id",269 "ORDER BY l.id",
267 (partner.id,))270 (partner.id,))
@@ -274,6 +277,19 @@
274277
275 return full_account278 return full_account
276279
280 def _get_line_sql(self):
281 return "SELECT sum(line.%s) " \
282 "FROM account_move_line line " \
283 "LEFT JOIN account_move m ON (line.move_id = m.id) " \
284 "WHERE line.account_id IN (" + self.account_ids + ") " \
285 "AND m.state = 'posted' "
286
287 def _get_credit_sql(self):
288 return self._get_line_sql() % ("credit", )
289
290 def _get_debit_sql(self):
291 return self._get_line_sql() % ("debit", )
292
277 def _sum_debit_partner(self, partner,data):293 def _sum_debit_partner(self, partner,data):
278294
279 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')295 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
@@ -283,13 +299,10 @@
283 else:299 else:
284 RECONCILE_TAG = "AND reconcile_id IS NULL"300 RECONCILE_TAG = "AND reconcile_id IS NULL"
285 if self.date_lst and data['form']['soldeinit'] :301 if self.date_lst and data['form']['soldeinit'] :
286 self.cr.execute(302 self.cr.execute(self._get_debit_sql() +
287 "SELECT sum(debit) " \303 "AND line.partner_id = %s " \
288 "FROM account_move_line " \304 "AND line.reconcile_id IS NULL " \
289 "WHERE partner_id = %s " \305 "AND line.date < %s ",
290 "AND account_id IN (" + self.account_ids + ") " \
291 "AND reconcile_id IS NULL " \
292 "AND date < %s " ,
293 (partner.id, self.date_lst[0],))306 (partner.id, self.date_lst[0],))
294 contemp = self.cr.fetchone()307 contemp = self.cr.fetchone()
295 if contemp != None:308 if contemp != None:
@@ -298,13 +311,10 @@
298 result_tmp = result_tmp + 0.0311 result_tmp = result_tmp + 0.0
299312
300 if self.date_lst_string:313 if self.date_lst_string:
301 self.cr.execute(314 self.cr.execute(self._get_debit_sql() +
302 "SELECT sum(debit) " \315 "AND line.partner_id = %s " \
303 "FROM account_move_line " \
304 "WHERE partner_id = %s " \
305 "AND account_id IN (" + self.account_ids + ") " \
306 " " + RECONCILE_TAG + " " \316 " " + RECONCILE_TAG + " " \
307 "AND date IN (" + self.date_lst_string + ") " ,317 "AND line.date IN (" + self.date_lst_string + ") ",
308 (partner.id,))318 (partner.id,))
309319
310 contemp = self.cr.fetchone()320 contemp = self.cr.fetchone()
@@ -322,13 +332,10 @@
322 else:332 else:
323 RECONCILE_TAG = "AND reconcile_id IS NULL"333 RECONCILE_TAG = "AND reconcile_id IS NULL"
324 if self.date_lst and data['form']['soldeinit'] :334 if self.date_lst and data['form']['soldeinit'] :
325 self.cr.execute(335 self.cr.execute(self._get_credit_sql() +
326 "SELECT sum(credit) " \336 "AND line.partner_id=%s " \
327 "FROM account_move_line " \337 "AND line.reconcile_id IS NULL " \
328 "WHERE partner_id=%s " \338 "AND line.date < %s ",
329 "AND account_id IN (" + self.account_ids + ") " \
330 "AND reconcile_id IS NULL " \
331 "AND date < %s " ,
332 (partner.id,self.date_lst[0],))339 (partner.id,self.date_lst[0],))
333 contemp = self.cr.fetchone()340 contemp = self.cr.fetchone()
334 if contemp != None:341 if contemp != None:
@@ -337,13 +344,10 @@
337 result_tmp = result_tmp + 0.0344 result_tmp = result_tmp + 0.0
338345
339 if self.date_lst_string:346 if self.date_lst_string:
340 self.cr.execute(347 self.cr.execute(self._get_credit_sql() +
341 "SELECT sum(credit) " \348 "AND line.partner_id=%s " \
342 "FROM account_move_line " \
343 "WHERE partner_id=%s " \
344 "AND account_id IN (" + self.account_ids + ") " \
345 " " + RECONCILE_TAG + " " \349 " " + RECONCILE_TAG + " " \
346 "AND date IN (" + self.date_lst_string + ") " ,350 "AND line.date IN (" + self.date_lst_string + ") ",
347 (partner.id,))351 (partner.id,))
348352
349 contemp = self.cr.fetchone()353 contemp = self.cr.fetchone()
@@ -363,13 +367,10 @@
363 else:367 else:
364 RECONCILE_TAG = "AND reconcile_id IS NULL"368 RECONCILE_TAG = "AND reconcile_id IS NULL"
365 if self.date_lst and data['form']['soldeinit'] :369 if self.date_lst and data['form']['soldeinit'] :
366 self.cr.execute(370 self.cr.execute(self._get_debit_sql() +
367 "SELECT sum(debit) " \371 "AND line.partner_id IN (" + self.partner_ids + ") " \
368 "FROM account_move_line " \372 "AND line.reconcile_id IS NULL " \
369 "WHERE partner_id IN (" + self.partner_ids + ") " \373 "AND line.date < %s ",
370 "AND account_id IN (" + self.account_ids + ") " \
371 "AND reconcile_id IS NULL " \
372 "AND date < %s " ,
373 (self.date_lst[0],))374 (self.date_lst[0],))
374 contemp = self.cr.fetchone()375 contemp = self.cr.fetchone()
375 if contemp != None:376 if contemp != None:
@@ -378,13 +379,10 @@
378 result_tmp = result_tmp + 0.0379 result_tmp = result_tmp + 0.0
379380
380 if self.date_lst_string:381 if self.date_lst_string:
381 self.cr.execute(382 self.cr.execute(self._get_debit_sql() +
382 "SELECT sum(debit) " \383 "AND line.partner_id IN (" + self.partner_ids + ") " \
383 "FROM account_move_line " \
384 "WHERE partner_id IN (" + self.partner_ids + ") " \
385 "AND account_id IN (" + self.account_ids + ") " \
386 " " + RECONCILE_TAG + " " \384 " " + RECONCILE_TAG + " " \
387 "AND date IN (" + self.date_lst_string + ") "385 "AND line.date IN (" + self.date_lst_string + ") ",
388 )386 )
389387
390 contemp = self.cr.fetchone()388 contemp = self.cr.fetchone()
@@ -406,13 +404,10 @@
406 else:404 else:
407 RECONCILE_TAG = "AND reconcile_id IS NULL"405 RECONCILE_TAG = "AND reconcile_id IS NULL"
408 if self.date_lst and data['form']['soldeinit'] :406 if self.date_lst and data['form']['soldeinit'] :
409 self.cr.execute(407 self.cr.execute(self._get_credit_sql() +
410 "SELECT sum(credit) " \408 "AND line.partner_id IN (" + self.partner_ids + ") " \
411 "FROM account_move_line " \409 "AND line.reconcile_id IS NULL " \
412 "WHERE partner_id IN (" + self.partner_ids + ") " \410 "AND line.date < %s ",
413 "AND account_id IN (" + self.account_ids + ") " \
414 "AND reconcile_id IS NULL " \
415 "AND date < %s " ,
416 (self.date_lst[0],))411 (self.date_lst[0],))
417 contemp = self.cr.fetchone()412 contemp = self.cr.fetchone()
418 if contemp != None:413 if contemp != None:
@@ -421,13 +416,10 @@
421 result_tmp = result_tmp + 0.0416 result_tmp = result_tmp + 0.0
422417
423 if self.date_lst_string:418 if self.date_lst_string:
424 self.cr.execute(419 self.cr.execute(self._get_credit_sql() +
425 "SELECT sum(credit) " \420 "AND line.partner_id IN (" + self.partner_ids + ") " \
426 "FROM account_move_line " \
427 "WHERE partner_id IN (" + self.partner_ids + ") " \
428 "AND account_id IN (" + self.account_ids + ") " \
429 " " + RECONCILE_TAG + " " \421 " " + RECONCILE_TAG + " " \
430 "AND date IN (" + self.date_lst_string + ") "422 "AND line.date IN (" + self.date_lst_string + ") ",
431 )423 )
432 contemp = self.cr.fetchone()424 contemp = self.cr.fetchone()
433 if contemp != None:425 if contemp != None: