From fe0754a549c600d9ce90b920c6e036355a95a20f Mon Sep 17 00:00:00 2001 From: "RavishchanraMurari (Open ERP)" Date: Tue, 22 Nov 2011 18:11:29 +0530 Subject: [PATCH 1/4] hr_payroll bzr revid: rmu@tinyerp.com-20111122124129-awp6gqiu2prp7egc --- addons/hr_payroll/hr_payroll.py | 10 ++++++++++ addons/hr_payroll/hr_payroll_report.xml | 2 +- addons/hr_payroll_account/hr_payroll_account.py | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) 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 = {} From 2e758fb463ba35c4820d93337ec577d3cdc451da Mon Sep 17 00:00:00 2001 From: "Amit (OpenERP)" Date: Wed, 23 Nov 2011 11:01:54 +0530 Subject: [PATCH 2/4] [IMP]:improved code bzr revid: apa@tinyerp.com-20111123053154-gsay5gufpz83vkns --- addons/hr_payroll/hr_payroll.py | 12 +++++------- addons/hr_payroll_account/hr_payroll_account.py | 17 ++++++++--------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 5b74e0b60b6..9363df8257e 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -299,14 +299,12 @@ class hr_payslip(osv.osv): } 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 + 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']) - ] + _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_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index 2ce8bc57e76..23d37ff0e56 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -34,21 +34,20 @@ 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 - + def _get_journal_id(self, cr, uid, *args): + model_data = self.pool.get('ir.model.data') + res = model_data.search(cr,uid, [('name', '=', 'expenses_journal')]) + if res:return model_data.browse(cr,uid,res[0]).res_id + return 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."), 'journal_id': fields.many2one('account.journal', 'Expense Journal',states={'draft': [('readonly', False)]}, readonly=True, required=True), 'move_id': fields.many2one('account.move', 'Accounting Entry', readonly=True), } - + _defaults = { - 'journal_id': _get_journal, + 'journal_id':_get_journal_id } def copy(self, cr, uid, id, default=None, context=None): From 7e3dbcf1e920fa120d26e7b4a47eef63e9dd0b39 Mon Sep 17 00:00:00 2001 From: "Amit (OpenERP)" Date: Wed, 23 Nov 2011 11:22:21 +0530 Subject: [PATCH 3/4] [IMP]:improved code bzr revid: apa@tinyerp.com-20111123055221-pnaz34zffzjw1eg2 --- addons/hr_payroll/hr_payroll_report.xml | 2 +- addons/hr_payroll/report/report_payslip.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_payroll/hr_payroll_report.xml b/addons/hr_payroll/hr_payroll_report.xml index f9f2741cc15..a1b3587313a 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="Payslip" + name="payslip" rml="hr_payroll/report/report_payslip.rml" string="Employee PaySlip" /> diff --git a/addons/hr_payroll/report/report_payslip.py b/addons/hr_payroll/report/report_payslip.py index 0fc37b44ac7..e2ef7dab974 100644 --- a/addons/hr_payroll/report/report_payslip.py +++ b/addons/hr_payroll/report/report_payslip.py @@ -44,6 +44,6 @@ class payslip_report(report_sxw.rml_parse): res = payslip_line.browse(self.cr, self.uid, ids) return res -report_sxw.report_sxw('report.test.pdf', 'hr.payslip', 'hr_payroll/report/report_payslip.rml', parser=payslip_report) +report_sxw.report_sxw('report.payslip', 'hr.payslip', 'hr_payroll/report/report_payslip.rml', parser=payslip_report) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From 9890c9e0442621c1982776eeb4f0bc098147f24b Mon Sep 17 00:00:00 2001 From: "Ravish Murari (OpenERP)" Date: Thu, 24 Nov 2011 10:53:27 +0530 Subject: [PATCH 4/4] date _from_hr bzr revid: rmu@tinyerp.com-20111124052327-a7beohzmnuab1pzc --- addons/hr_payroll/hr_payroll_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 01fe270710d..c0538c46d37 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -262,7 +262,7 @@ - +