[FIX] hr_payroll_account: do not create entries with amount at 0
authorMartin Trigaux <mat@openerp.com>
Tue, 30 Sep 2014 14:17:57 +0000 (16:17 +0200)
committerMartin Trigaux <mat@openerp.com>
Tue, 30 Sep 2014 14:37:24 +0000 (16:37 +0200)
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

addons/hr_payroll_account/hr_payroll_account.py

index 9e89268..d6385c6 100644 (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)