Odoo Help

Welcome!

This community 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.

0

Confirm hr.payslip when closing hr.payslip.run

By
Koffi KPONOUGLO
on 1/9/15, 12:34 PM 599 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
            

 

0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


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

Hello,

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 ...

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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