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

Call a function in salary rules payslip

By
emna
on 11/2/16, 8:54 AM 86 views

Hello everybody,

I add a method in hr.payslip:

_number_of_months(self, cr, uid, ids, date_from, date_to, context=None):

     date1 = datetime.strptime(self.browse(cr, uid, ids, context=context).date_from, '%Y-%m-%d')

    date2 = datetime.strptime(self.browse(cr, uid, ids, context=context).date_to, '%Y-%m-%d')

    p= (date2.year - date1.year) * 12 + (date2.month - date1.month)

    return p

i call this function in salary rule like this:

result = payslip._number_of_months(payslip.date_from, payslip.date_to)

but this not work

Please some helps


Thank you

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: 11/2/16, 8:54 AM
Seen: 86 times
Last updated: 11/2/16, 12:12 PM