[FIX] hr_payroll_account: used float_compare() instead of direct comparing between two floats to avoid python rounding
bzr revid: rha@tinyerp.com-20140304113117-smy5gb9e92lcuji8
This commit is contained in:
parent
b201dc79b7
commit
5d2e59e5e4
|
@ -24,7 +24,7 @@ from openerp import netsvc
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
from openerp.osv import fields, osv
|
from openerp.osv import fields, osv
|
||||||
from openerp.tools import config
|
from openerp.tools import config, float_compare
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
class hr_payslip(osv.osv):
|
class hr_payslip(osv.osv):
|
||||||
|
@ -87,6 +87,7 @@ class hr_payslip(osv.osv):
|
||||||
def process_sheet(self, cr, uid, ids, context=None):
|
def process_sheet(self, cr, uid, ids, context=None):
|
||||||
move_pool = self.pool.get('account.move')
|
move_pool = self.pool.get('account.move')
|
||||||
period_pool = self.pool.get('account.period')
|
period_pool = self.pool.get('account.period')
|
||||||
|
precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Payroll')
|
||||||
timenow = time.strftime('%Y-%m-%d')
|
timenow = time.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
for slip in self.browse(cr, uid, ids, context=context):
|
for slip in self.browse(cr, uid, ids, context=context):
|
||||||
|
@ -151,7 +152,7 @@ class hr_payslip(osv.osv):
|
||||||
line_ids.append(credit_line)
|
line_ids.append(credit_line)
|
||||||
credit_sum += credit_line[2]['credit'] - credit_line[2]['debit']
|
credit_sum += credit_line[2]['credit'] - credit_line[2]['debit']
|
||||||
|
|
||||||
if debit_sum > credit_sum:
|
if float_compare(credit_sum, debit_sum, precision_digits=precision) == -1:
|
||||||
acc_id = slip.journal_id.default_credit_account_id.id
|
acc_id = slip.journal_id.default_credit_account_id.id
|
||||||
if not acc_id:
|
if not acc_id:
|
||||||
raise osv.except_osv(_('Configuration Error!'),_('The Expense Journal "%s" has not properly configured the Credit Account!')%(slip.journal_id.name))
|
raise osv.except_osv(_('Configuration Error!'),_('The Expense Journal "%s" has not properly configured the Credit Account!')%(slip.journal_id.name))
|
||||||
|
@ -167,7 +168,7 @@ class hr_payslip(osv.osv):
|
||||||
})
|
})
|
||||||
line_ids.append(adjust_credit)
|
line_ids.append(adjust_credit)
|
||||||
|
|
||||||
elif debit_sum < credit_sum:
|
elif float_compare(debit_sum, credit_sum, precision_digits=precision) == -1:
|
||||||
acc_id = slip.journal_id.default_debit_account_id.id
|
acc_id = slip.journal_id.default_debit_account_id.id
|
||||||
if not acc_id:
|
if not acc_id:
|
||||||
raise osv.except_osv(_('Configuration Error!'),_('The Expense Journal "%s" has not properly configured the Debit Account!')%(slip.journal_id.name))
|
raise osv.except_osv(_('Configuration Error!'),_('The Expense Journal "%s" has not properly configured the Debit Account!')%(slip.journal_id.name))
|
||||||
|
|
Loading…
Reference in New Issue