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

read the drop down field from HR in Payroll Salary Rules

By
Ken Kasai
on 1/29/15, 7:05 AM 926 views

I created a salary rule and I created a python condition in Payroll Salary Rules. Im trying to get the value from gender (drop down list) field in hr. But seems like isnt working. need help. thank you

Python Condition:

if (employee.gender== "Male"):
  result = 1
elif (employee.gender== "Female"):
  result = 2

 

thank you. but how about if I want to get the value from a custom object and the field is many2one and also drop down list with create and edit?

Ken Kasai
on 1/29/15, 7:38 AM

many2one is different from selection. It is basically a foreign key to another model/table. The value stored is the (database) id. So, if you want to compare it to a specific id, use field_to_compare.id = 999 (where 999 is the database id). Further you can compare it with the different fields that field_to_compare has.

Ivan
on 1/30/15, 12:08 PM
0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 1/29/15, 7:18 AM

In HR module, the gender field is defined as 
'gender': fields.selection([('male', 'Male'),('female', 'Female')], 'Gender'),

So, to check whether gender is male or female, we use the key instead of value to check any SELECTION.
if (employee.gender== "male"):
  result = 1
elif (employee.gender== "
female"):
  result = 2

how i can set date in condition change gender with date

ahmad safi
on 3/2/15, 3:59 AM

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/29/15, 7:05 AM
Seen: 926 times
Last updated: 3/16/15, 8:10 AM