Odoo Help


Confirm hr.payslip when closing hr.payslip.run

on 1/9/15, 12:34 PM 1,079 views

With this fonction below, my goal is to write hr.payslip.run lines states into done when i am closing it. So i write this but anything happenp on hr.payslip.run lines states

    def validate_sheet(self, cr, uid, ids, context=None):
        emp_pool = self.pool.get('hr.employee')
        slip_pool = self.pool.get('hr.payslip')
        run_pool = self.pool.get('hr.payslip.run')              
        for sheet in slip_pool.browse(cr, uid, ids, context=None):                         
            date_end = sheet.contract_id and sheet.contract_id.date_end or False
            date_from = sheet.date_from or False
            if date_end < date_from:
                slip_pool.write(cr, uid, ids, {'state':'echu'}, context=context)         
            slip_pool.write(cr, uid, ids, {'state':'done'}, context=context)
            self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
        return True


--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 1/10/15, 10:58 AM


You can inherit hr.payslip.run and override close_payslip_run function and call the process_sheet function in hr.payslip model, so this is the code :

class hr_payslip_run(osv.osv):
    _inherit = 'hr.payslip.run'

    def close_payslip_run(self, cr, uid, ids, context=None):
        slip_pool = self.pool.get('hr.payslip')
        slip_ids = [x.id for x in self.browse(cr, uid,ids[0], context=context).slip_ids]
        slip_pool.process_sheet(cr, uid, slip_ids, context=context)
        return self.write(cr, uid, ids, {'state': 'close'}, context=context)

I hope this could help ...

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/9/15, 12:34 PM
Seen: 1079 times
Last updated: 3/16/15, 8:10 AM