Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6331 Lượt xem

How do I get the age of the employee when defining a salary rules like 

if age < 35:

result = 0.17 * categories.BASIC

elif age >= 35 and age < 45:

result = 0.17 * categories.BASIC

elif age >= 45 and age < 50:

result = 0.17 * categories.BASIC

elif age >= 50 and age < 55:

result = 0.16 * categories.BASIC

elif age >= 55 and age < 60:

result = 0.12 * categories.BASIC

elif age >= 55 and age < 60:

result = 0.085 * categories.BASIC

elif age > 65:

result = 0.075 * categories.BASIC

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I have to edit code  to openerp/addons/hr/hr.py

import time
from datetime import datetime
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
...
class hr_employee(osv.osv):
    _name = "hr.employee" 
    _description = "Employee" 
    _order = 'name_related'
    _inherits = {'resource.resource': "resource_id"}
    _inherit = ['mail.thread']

...

    def get_age(self):
        if not  self.birthday:
            return 0
        birth = datetime.strptime(self.birthday, DEFAULT_SERVER_DATE_FORMAT)
        today = datetime.strptime(time.strftime(DEFAULT_SERVER_DATE_FORMAT), DEFAULT_SERVER_DATE_FORMAT)
        delta = today - birth
        return delta.days / 365

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 22
2918
0
thg 3 15
3233
2
thg 6 22
12005
1
thg 5 22
2241
2
thg 3 15
7304