summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorFlorent de Labarre <florent.mirieu@gmail.com>2017-05-30 13:49:13 +0200
committerThibault Delavallée <tde@odoo.com>2017-06-02 17:19:57 +0200
commit9675c0fcfb15bb7affe2fd8d22dacafe4ed7c2ae (patch)
tree378c03f91f9e2830af2ce077cffc13e4005e75ef /addons
parent54e469c41dcfee024db4b4e70e79fa375ca5d95c (diff)
[FIX] hr_holidays: fix gray color on saturday/sunday not working with other language than English
Instead of checking that the day short name is effectively Sat or Sun it now checks that it is the saturday or sunday based on weekday. It is located in a method to ease inheritance or implementation of specific behavior based on some calendar if necessary. Closes #17294 .
Diffstat (limited to 'addons')
-rw-r--r--addons/hr_holidays/report/holidays_summary_report.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py
index 3fcff6838f1..d77e664c9e9 100644
--- a/addons/hr_holidays/report/holidays_summary_report.py
+++ b/addons/hr_holidays/report/holidays_summary_report.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+import calendar
+
from datetime import timedelta
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
@@ -16,12 +18,15 @@ class HrHolidaySummaryReport(models.AbstractModel):
'end_date': fields.Date.to_string(st_date + relativedelta(days=59)),
'holiday_type': 'Confirmed and Approved' if holiday_type == 'both' else holiday_type
}
+
+ def _date_is_day_off(self, date):
+ return date.weekday() in (calendar.SATURDAY, calendar.SUNDAY,)
def _get_day(self, start_date):
res = []
start_date = fields.Date.from_string(start_date)
for x in range(0, 60):
- color = '#ababab' if start_date.strftime('%a') == 'Sat' or start_date.strftime('%a') == 'Sun' else ''
+ color = '#ababab' if self._date_is_day_off(start_date) else ''
res.append({'day_str': start_date.strftime('%a'), 'day': start_date.day , 'color': color})
start_date = start_date + relativedelta(days=1)
return res
@@ -48,7 +53,7 @@ class HrHolidaySummaryReport(models.AbstractModel):
for index in range(0, 60):
current = start_date + timedelta(index)
res.append({'day': current.day, 'color': ''})
- if current.strftime('%a') == 'Sat' or current.strftime('%a') == 'Sun':
+ if self._date_is_day_off(current) :
res[index]['color'] = '#ababab'
# count and get leave summary details.
holiday_type = ['confirm','validate'] if holiday_type == 'both' else ['confirm'] if holiday_type == 'Confirmed' else ['validate']