4 答案
Keep a new field "month" in hr_payslip model and on saving the record it should be updated as follows,
month = dt.strptime(date_from,'%Y-%m-%d').month
res['value'].update({'month': month})
--------------------------------------
We are using the above month variable to index the days in a month which is given as a list,
result=(contract.wage/[0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] [payslip.month])*worked_days.Unpaid and worked_days.Unpaid.number_of_days or False
has anyone got the solution , how can we remove 31 with the number of days of the month for which we are calculating the payslip ??
# Get the no of days ...........
atej = str(payslip.date_to)
datek = str(payslip.date_from)
dj = datej[-2:]
x=0
new = 0
while (x<=31):
x= x+1
if str(x) == dj or "0"+str(x) == dj:
new= x
dk = datek[-2:]
y=0
old = 0
while (y<=31):
y= y+1
if str(y) == dk or "0"+str(y) == dk:
old= y
no_of_days = new-old + 1
result = no_of_days
Finally I found the solution .. the condition needed for this rule
result=worked_days.Unpaid and worked_days.Unpaid.number_of_days or False
and then working correctly
the following link help in this problem
http://help.openerp.com/question/14645/unpaid-leaves-is-not-decrease-in-the-salary-computation/#14782