From c63d065d7546e405d453cbc045829efe638d6eef Mon Sep 17 00:00:00 2001 From: ced <> Date: Mon, 30 Jul 2007 13:35:11 +0000 Subject: [PATCH] account, base: fix rounding for reconcile Add new method on res.currency to check if a amount of currency must be considered as zero in regards of the definition of the currency. bzr revid: ced-deffca6a9bc83dbe4663737fb5bc68296dbe5ff3 --- addons/account/account_move_line.py | 5 +++-- addons/account/wizard/wizard_pay_invoice.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 0ed42c06902..96e24f0e251 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -293,11 +293,12 @@ class account_move_line(osv.osv): #TODO: move this check to a constraint in the account_move_reconcile object if len(r) != 1: raise osv.except_osv('Error', 'Entries are not of the same account or already reconciled ! ') - if not self.pool.get('account.account').read(cr, uid, [account_id], ['reconcile'], context=context)[0]['reconcile']: + account = self.pool.get('account.account').browse(cr, uid, account_id, context=context) + if not account.reconcile: raise osv.except_osv('Error', 'The account is not defined to be reconcile !') if r[0][1] != None: raise Exception('Some entries are already reconciled !') - if writeoff != 0: + if self.pool.get('res.currency').is_zero(cr, uid, account.company_id.currency_id, writeoff): if not writeoff_acc_id: raise osv.except_osv('Warning', 'You have to provide an account for the write off entry !') if writeoff > 0: diff --git a/addons/account/wizard/wizard_pay_invoice.py b/addons/account/wizard/wizard_pay_invoice.py index 31b1274ca30..757c5e25a57 100644 --- a/addons/account/wizard/wizard_pay_invoice.py +++ b/addons/account/wizard/wizard_pay_invoice.py @@ -63,7 +63,8 @@ def _trans_reconcile(self, cr, uid, data, context): def _wo_check(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context) - if round(data['form']['amount'], 2) == round(invoice.amount_total, 2): + if pool.get('res.currency').is_zero(cr, uid, invoice.currency_id, + (data['form']['amount'] - invoice.amount_total)): return 'reconcile' return 'addendum'