From cad6715087c0a7a249ccc0566e1dbcc3f9ae4c64 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Mon, 16 Jan 2012 18:04:45 +0530 Subject: [PATCH 1/3] [FIX] account_voucher : Advanced payment+customer credit, wrong open balance lp bug: https://launchpad.net/bugs/901089 fixed bzr revid: mdi@tinyerp.com-20120116123445-5vogciqrwotteq5r --- addons/account_voucher/account_voucher.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 1f8c86161c1..50cde3a2c01 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -593,10 +593,6 @@ class account_voucher(osv.osv): account_move_lines = move_line_pool.browse(cr, uid, ids, context=context) for line in account_move_lines: - if line.credit and line.reconcile_partial_id and ttype == 'receipt': - continue - if line.debit and line.reconcile_partial_id and ttype == 'payment': - continue if invoice_id: if line.invoice.id == invoice_id: #if the invoice linked to the voucher line is equal to the invoice_id in context @@ -622,10 +618,6 @@ class account_voucher(osv.osv): #voucher line creation for line in account_move_lines: - if line.credit and line.reconcile_partial_id and ttype == 'receipt': - continue - if line.debit and line.reconcile_partial_id and ttype == 'payment': - continue if line.currency_id and currency_id==line.currency_id.id: amount_original = abs(line.amount_currency) amount_unreconciled = abs(line.amount_residual_currency) @@ -1051,7 +1043,7 @@ class account_voucher(osv.osv): voucher_currency = voucher_brw.currency_id and voucher_brw.currency_id.id or voucher_brw.journal_id.company_id.currency_id.id # We want to set it on the account move line as soon as the original line had a foreign currency if line.move_line_id.currency_id and line.move_line_id.currency_id.id != company_currency: - # we compute the amount in that foreign currency. + # we compute the amount in that foreign currency. if line.move_line_id.currency_id.id == current_currency: # if the voucher and the voucher line share the same currency, there is no computation to do sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1 @@ -1270,7 +1262,7 @@ class account_voucher_line(osv.osv): def _currency_id(self, cr, uid, ids, name, args, context=None): ''' - This function returns the currency id of a voucher line. It's either the currency of the + This function returns the currency id of a voucher line. It's either the currency of the associated move line (if any) or the currency of the voucher or the company currency. ''' res = {} From 590c143fe3a6c99098d64e592126f9e68d1f3e82 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 24 Feb 2012 10:02:35 +0100 Subject: [PATCH 2/3] [FIX] account_voucher: correct fix for lp:901089 lp bug: https://launchpad.net/bugs/901089 fixed bzr revid: qdp-launchpad@openerp.com-20120224090235-ykpgfsfa3ail0pq7 --- addons/account_voucher/account_voucher.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 50cde3a2c01..50c18e603d2 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -592,7 +592,14 @@ class account_voucher(osv.osv): ids.reverse() account_move_lines = move_line_pool.browse(cr, uid, ids, context=context) + #compute the total debit/credit and look for a matching open amount or invoice for line in account_move_lines: + #if the line is partially reconciled, then we must pay attention to display it only once and in the good o2m + if line.debit and line.reconcile_partial_id and ttype == 'receipt': + continue + if line.credit and line.reconcile_partial_id and ttype == 'payment': + continue + if invoice_id: if line.invoice.id == invoice_id: #if the invoice linked to the voucher line is equal to the invoice_id in context @@ -618,6 +625,12 @@ class account_voucher(osv.osv): #voucher line creation for line in account_move_lines: + #if the line is partially reconciled, then we must pay attention to display it only once and in the good o2m + if line.debit and line.reconcile_partial_id and ttype == 'receipt': + continue + if line.credit and line.reconcile_partial_id and ttype == 'payment': + continue + if line.currency_id and currency_id==line.currency_id.id: amount_original = abs(line.amount_currency) amount_unreconciled = abs(line.amount_residual_currency) From bdf3e9bca3e4c9cfbe2d1e0f15dc75070470ce65 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 24 Feb 2012 11:23:05 +0100 Subject: [PATCH 3/3] [FIX] account_voucher: correct fix for lp:901089 lp bug: https://launchpad.net/bugs/901089 fixed bzr revid: qdp-launchpad@openerp.com-20120224102305-6yqsk0vaasydcxum --- addons/account_voucher/account_voucher.py | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 6253720e094..3ed173cca85 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -547,6 +547,21 @@ class account_voucher(osv.osv): @return: Returns a dict which contains new values, and context """ + def _remove_noise_in_o2m(): + """if the line is partially reconciled, then we must pay attention to display it only once and + in the good o2m. + This function returns True if the line is considered as noise and should not be displayed + """ + if line.reconcile_partial_id: + sign = 1 if ttype == 'receipt' else -1 + if currency_id == line.currency_id.id: + if line.amount_residual_currency * sign <= 0: + return True + else: + if line.amount_residual * sign <= 0: + return True + return False + if context is None: context = {} context_multi_currency = context.copy() @@ -612,10 +627,7 @@ class account_voucher(osv.osv): #compute the total debit/credit and look for a matching open amount or invoice for line in account_move_lines: - #if the line is partially reconciled, then we must pay attention to display it only once and in the good o2m - if line.debit and line.reconcile_partial_id and ttype == 'receipt': - continue - if line.credit and line.reconcile_partial_id and ttype == 'payment': + if _remove_noise_in_o2m(): continue if invoice_id: @@ -643,10 +655,7 @@ class account_voucher(osv.osv): #voucher line creation for line in account_move_lines: - #if the line is partially reconciled, then we must pay attention to display it only once and in the good o2m - if line.debit and line.reconcile_partial_id and ttype == 'receipt': - continue - if line.credit and line.reconcile_partial_id and ttype == 'payment': + if _remove_noise_in_o2m(): continue if line.currency_id and currency_id==line.currency_id.id: