From f307cb1822f68c721b18f533c9ab9f00613f66a8 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 24 Jan 2011 15:25:29 +0530 Subject: [PATCH 1/3] [FIX]account: 6.0.1 account - legal reports - 'Display accounts' dropdown lp bug: https://launchpad.net/bugs/706287 fixed bzr revid: ara@tinyerp.com-20110124095529-u5wvf5sta8fdt9ed --- addons/account/report/account_balance.py | 4 ++-- addons/account/report/account_balance_sheet.py | 4 ++-- addons/account/report/account_profit_loss.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 8fe9af39e00..fbf8225010f 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -89,10 +89,10 @@ class account_balance(report_sxw.rml_parse, common_report_header): self.sum_debit += account_rec['debit'] self.sum_credit += account_rec['credit'] if disp_acc == 'bal_movement': - if currency_obj.is_zero(self.cr, self.uid, currency, res['credit']) > 0 or currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) > 0 or currency_obj.is_zero(self.cr, self.uid, currency, res['balance']) != 0: + if currency_obj.is_zero(self.cr, self.uid, currency, res['credit']) > 0 or currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) > 0 or not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']): self.result_acc.append(res) elif disp_acc == 'bal_solde': - if currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) != 0: + if not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']): self.result_acc.append(res) else: self.result_acc.append(res) diff --git a/addons/account/report/account_balance_sheet.py b/addons/account/report/account_balance_sheet.py index 8762b44e1e2..4be402dff7b 100644 --- a/addons/account/report/account_balance_sheet.py +++ b/addons/account/report/account_balance_sheet.py @@ -143,10 +143,10 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header) if typ == 'asset' and account.type <> 'view' and (account.debit <> account.credit): self.result_sum_cr += account.balance if data['form']['display_account'] == 'bal_movement': - if currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.balance) != 0: + if currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): accounts_temp.append(account_dict) elif data['form']['display_account'] == 'bal_solde': - if currency_pool.is_zero(self.cr, self.uid, currency, account.balance) != 0: + if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): accounts_temp.append(account_dict) else: accounts_temp.append(account_dict) diff --git a/addons/account/report/account_profit_loss.py b/addons/account/report/account_profit_loss.py index c17d2e7b23e..5bb3035ec24 100644 --- a/addons/account/report/account_profit_loss.py +++ b/addons/account/report/account_profit_loss.py @@ -113,10 +113,10 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header): if typ == 'income' and account.type <> 'view' and (account.debit <> account.credit): self.result_sum_cr += abs(account.debit - account.credit) if data['form']['display_account'] == 'bal_movement': - if currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.balance) != 0: + if currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): accounts_temp.append(account) elif data['form']['display_account'] == 'bal_solde': - if currency_pool.is_zero(self.cr, self.uid, currency, account.balance) != 0: + if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): accounts_temp.append(account) else: accounts_temp.append(account) From b5cad281c42ae8b5bdf685f7bd9890b0c50e041a Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 24 Jan 2011 16:16:10 +0530 Subject: [PATCH 2/3] [IMP]account - legal reports - 'Display accounts' dropdown bzr revid: ara@tinyerp.com-20110124104610-oiznlwb9r14y45l3 --- addons/account/report/account_balance.py | 2 +- addons/account/report/account_balance_sheet.py | 2 +- addons/account/report/account_profit_loss.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index fbf8225010f..5d9cfac5699 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -89,7 +89,7 @@ class account_balance(report_sxw.rml_parse, common_report_header): self.sum_debit += account_rec['debit'] self.sum_credit += account_rec['credit'] if disp_acc == 'bal_movement': - if currency_obj.is_zero(self.cr, self.uid, currency, res['credit']) > 0 or currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) > 0 or not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']): + if not currency_obj.is_zero(self.cr, self.uid, currency, res['credit']) > 0 or not currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) > 0 or not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']): self.result_acc.append(res) elif disp_acc == 'bal_solde': if not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']): diff --git a/addons/account/report/account_balance_sheet.py b/addons/account/report/account_balance_sheet.py index 4be402dff7b..f22061a5785 100644 --- a/addons/account/report/account_balance_sheet.py +++ b/addons/account/report/account_balance_sheet.py @@ -143,7 +143,7 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header) if typ == 'asset' and account.type <> 'view' and (account.debit <> account.credit): self.result_sum_cr += account.balance if data['form']['display_account'] == 'bal_movement': - if currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): + if not currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): accounts_temp.append(account_dict) elif data['form']['display_account'] == 'bal_solde': if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): diff --git a/addons/account/report/account_profit_loss.py b/addons/account/report/account_profit_loss.py index 5bb3035ec24..bd1635e91fc 100644 --- a/addons/account/report/account_profit_loss.py +++ b/addons/account/report/account_profit_loss.py @@ -113,7 +113,7 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header): if typ == 'income' and account.type <> 'view' and (account.debit <> account.credit): self.result_sum_cr += abs(account.debit - account.credit) if data['form']['display_account'] == 'bal_movement': - if currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): + if not currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): accounts_temp.append(account) elif data['form']['display_account'] == 'bal_solde': if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance): From 407c58d8fb7b06c60b933ac3b8f976af68240a81 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Tue, 25 Jan 2011 12:41:33 +0530 Subject: [PATCH 3/3] [FIX] Account: Reconcile with Write-Off lp bug: https://launchpad.net/bugs/706107 fixed bzr revid: mra@mra-laptop-20110125071133-gu9z7nftu7u7zr4q --- addons/account_voucher/account_voucher.py | 51 +++++++++++++------ .../voucher_payment_receipt_view.xml | 10 ++-- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 6c6f2865ceb..886848c0902 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -142,31 +142,50 @@ class account_voucher(osv.osv): res['arch'] = etree.tostring(doc) return res - def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount): + def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount, context=None): + if context is None: + context = {} debit = credit = 0.0 - for l in line_dr_ids: - debit += l['amount'] - for l in line_cr_ids: - credit += l['amount'] + if context.get('based_on', 'amount') == 'amount_unreconciled': + for l in line_dr_ids: + debit += l['amount_unreconciled'] + for l in line_cr_ids: + credit += l['amount_unreconciled'] + else: + for l in line_dr_ids: + debit += l['amount'] + for l in line_cr_ids: + credit += l['amount'] return abs(amount - abs(credit - debit)) - def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount): + def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, context=None): + if not context: + context = {} + context.update({'based_on': context.get('based_on', False)}) if not line_dr_ids and not line_cr_ids: return {'value':{}} line_dr_ids = [x[2] for x in line_dr_ids] line_cr_ids = [x[2] for x in line_cr_ids] - return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount)}} + return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount, context=context)}, 'context': context} def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None): if not ids: return {} res = {} debit = credit = 0.0 - for voucher in self.browse(cr, uid, ids, context=context): - for l in voucher.line_dr_ids: - debit += l.amount - for l in voucher.line_cr_ids: - credit += l.amount - res[voucher.id] = abs(voucher.amount - abs(credit - debit)) + if context.get('based_on', 'amount') == 'amount_unreconciled': + for voucher in self.browse(cr, uid, ids, context=context): + for l in voucher.line_dr_ids: + debit += l.amount_unreconciled + for l in voucher.line_cr_ids: + credit += l.amount_unreconciled + res[voucher.id] = abs(voucher.amount - abs(credit - debit)) + else: + for voucher in self.browse(cr, uid, ids, context=context): + for l in voucher.line_dr_ids: + debit += l.amount + for l in voucher.line_cr_ids: + credit += l.amount + res[voucher.id] = abs(voucher.amount - abs(credit - debit)) return res _name = 'account.voucher' @@ -517,8 +536,10 @@ class account_voucher(osv.osv): default['value']['pre_line'] = 1 elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0: default['value']['pre_line'] = 1 - default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price) - + ctx = context.copy() + ctx.update({'based_on': 'amount_unreconciled'}) + default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price, context=ctx) + default['context'] = ctx return default def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None): diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index e73354eb59a..d6e382d729e 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -106,7 +106,7 @@ - + - + @@ -308,7 +308,7 @@ - + - + @@ -379,7 +379,7 @@ - +