diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index affd81cce6d..5b74e0b60b6 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -297,6 +297,16 @@ class hr_payslip(osv.osv): self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id, } + + def _check_dates(self, cr, uid, ids, context=None): + for i in self.read(cr, uid, ids, ['date_from', 'date_to'], context=context): + if i['date_from'] > i['date_to']: + return False + return True + + _constraints = [ + (_check_dates, 'Error! Payslip from-date must be lower then contract to-date.', ['date_from', 'date_to']) + ] def copy(self, cr, uid, id, default=None, context=None): if not default: diff --git a/addons/hr_payroll/hr_payroll_report.xml b/addons/hr_payroll/hr_payroll_report.xml index a0027d70e0d..f9f2741cc15 100644 --- a/addons/hr_payroll/hr_payroll_report.xml +++ b/addons/hr_payroll/hr_payroll_report.xml @@ -6,7 +6,7 @@ auto="False" id="payslip_report" model="hr.payslip" - name="test.pdf" + name="Payslip" rml="hr_payroll/report/report_payslip.rml" string="Employee PaySlip" /> diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index 3463713d37d..2ce8bc57e76 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -33,6 +33,13 @@ class hr_payslip(osv.osv): ''' _inherit = 'hr.payslip' _description = 'Pay Slip' + + def _get_journal(self, cr, uid, context=None): + if context is None: + context = {} + journal_obj = self.pool.get('account.journal') + res = journal_obj.search(cr, uid, [('type', '=','sale')]) + return res and res[0] or False _columns = { 'period_id': fields.many2one('account.period', 'Force Period',states={'draft': [('readonly', False)]}, readonly=True, domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."), @@ -40,6 +47,10 @@ class hr_payslip(osv.osv): 'move_id': fields.many2one('account.move', 'Accounting Entry', readonly=True), } + _defaults = { + 'journal_id': _get_journal, + } + def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {}