跳至內容
選單
此問題已被標幟
1508 瀏覽次數

I was attempting to calculate a payslip and add a salary rule that multiplies overtime hours by 2.5 if an employee worked on a holiday. However, I couldn't determine whether a specific work date falls on a holiday. Is there a way to check if a given date is a holiday? Also, how can I work with datetime to handle this?

# gpt suggested this 
def is_holiday():
    today = payslip.date_from.date() 
    holidays = payslip.env['resource.calendar.leaves'].search([
        ('date_from', '<=', today),
        ('date_to', '>=', today)
    ])
    return bool(holidays)


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
7月 25
3659
1
7月 25
2800
0
12月 23
1374
0
9月 20
1557
1
3月 20
3983