[FIX] hr_payroll_account: do not create entries with amount at 0

If the salary compuation gives a salary of zero, skip the creation of the account.move.line (not good to have lines at 0).
Fixes lp:1298116, opw 605816
This commit is contained in:
Martin Trigaux 2014-09-30 16:17:57 +02:00
parent 937fb4aa11
commit 7201bc0250
1 changed files with 4 additions and 1 deletions

View File

@ -24,7 +24,7 @@ from openerp import netsvc
from datetime import date, datetime, timedelta
from openerp.osv import fields, osv
from openerp.tools import config, float_compare
from openerp.tools import float_compare, float_is_zero
from openerp.tools.translate import _
class hr_payslip(osv.osv):
@ -112,6 +112,8 @@ class hr_payslip(osv.osv):
}
for line in slip.details_by_salary_rule_category:
amt = slip.credit_note and -line.total or line.total
if float_is_zero(amt, precision_digits=precision):
continue
partner_id = line.salary_rule_id.register_id.partner_id and line.salary_rule_id.register_id.partner_id.id or default_partner_id
debit_account_id = line.salary_rule_id.account_debit.id
credit_account_id = line.salary_rule_id.account_credit.id
@ -183,6 +185,7 @@ class hr_payslip(osv.osv):
'credit': 0.0,
})
line_ids.append(adjust_debit)
move.update({'line_id': line_ids})
move_id = move_pool.create(cr, uid, move, context=context)
self.write(cr, uid, [slip.id], {'move_id': move_id, 'period_id' : period_id}, context=context)