# Is this a recursion problem? Whats the best way to write this function in openerp?

By
on 12/8/13, 2:42 AM 1,113 views

I'm relatively new to python and openerp and in my new module, I'm trying to write a function that does this:

``````monthly_pay = float(int(annual_pay_1 / number_of_months))
annual_pay_2 = monthly_pay * number_of_months
diff = annual_pay_1 - annual_pay_2
jan_pay = monthly_pay + diff
feb_pay = jan_pay + monthly_pay
mar_pay = feb_pay + monthly_pay
apr_pay = mar_pay + monthly_pay
may_pay = apr_pay + monthly_pay
jun_pay = may_pay + monthly_pay
jul_pay = jun_pay + monthly_pay
aug_pay = jul_pay + monthly_pay
sep_pay = aug_pay + monthly_pay
oct_pay = sep_pay + monthly_pay
nov_pay = oct_pay + monthly_pay
dec_pay = nov_pay + monthly_pay
``````

Sometimes, the number or months may not be up to 12. It could be say 8 or 9 for instance and it doesn't necessarily start from january or end in december.

Is this a proper recursion or for loop problem? Whats the best way to write the function to handle this?

peterm
On 12/9/13, 3:55 AM

Could be this (not complete):

``````start_month=3
number_of_months=7
annual_pay_1=40000

monthly_pay = float(int(annual_pay_1 / number_of_months))
annual_pay_2 = monthly_pay * number_of_months
diff = annual_pay_1 - annual_pay_2

pay = [0] * 12

pay[start_month] = monthly_pay + diff
for i in range(start_month+1, start_month+number_of_months):
pay[i] = monthly_pay

print(pay)
``````

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.

0 follower(s)

### Stats

 Asked: 12/8/13, 2:42 AM Seen: 1113 times Last updated: 3/16/15, 8:10 AM