[IMP] hr-luncheon-voucher: add effective attendance as criteria

The calculation of eligible attendances now also depends on the
effective attendance period field.
This commit is contained in:
Stéphan Sainléger
2023-01-18 15:16:05 +01:00
parent 2a6fb40a15
commit eab094677a
3 changed files with 8 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ Configuration
1. Go to ``Configuration > Technical > Calendar > Meeting Types`` and define the meeting categories which cancel the daily luncheon voucher distribution. 1. Go to ``Configuration > Technical > Calendar > Meeting Types`` and define the meeting categories which cancel the daily luncheon voucher distribution.
2. Go to ``Configuration > General Settings > Employees`` and define if employees need to work the whole day to get a luncheon voucher. 2. Go to ``Configuration > General Settings > Employees`` and define if employees need to work the whole day to get a luncheon voucher.
3. Go to ``Employees`` and define for each employee the default number of luncheon vouchers to distribute in each distribution campaign. 3. Go to ``Employees`` and define for each employee the default number of luncheon vouchers to distribute in each distribution campaign.
4. Go to ``Configuration > Technical > Resource > Working Times`` and create Working Times for each combination of attendance that you have in your company. Do not forget to indicate which period are effectively attended.
Use Use
=== ===

View File

@@ -2,7 +2,7 @@
{ {
"name": "HR Luncheon Voucher", "name": "HR Luncheon Voucher",
"category": "Human Resources", "category": "Human Resources",
"version": "14.0.1.0", "version": "14.0.1.1.0",
"summary": "Manage luncheon vouchers credit and distribution", "summary": "Manage luncheon vouchers credit and distribution",
"author": "Elabore", "author": "Elabore",
"website": "https://elabore.coop/", "website": "https://elabore.coop/",
@@ -13,6 +13,7 @@
"base", "base",
"calendar", "calendar",
"hr", "hr",
"hr_effective_attendance_period",
"hr_holidays", "hr_holidays",
"resource", "resource",
], ],

View File

@@ -7,7 +7,11 @@ class ResourceCalendar(models.Model):
_inherit = "resource.calendar" _inherit = "resource.calendar"
def _retrieve_day_matching_attendances(self, day): def _retrieve_day_matching_attendances(self, day):
domain = [("calendar_id", "=", self.id),("dayofweek", "=", day.weekday())] domain = [
("calendar_id", "=", self.id),
("dayofweek", "=", day.weekday()),
("effective_attendance_period", "=", True)
]
if self.two_weeks_calendar: if self.two_weeks_calendar:
# Employee has Even/Odd weekly calendar # Employee has Even/Odd weekly calendar
week_type = 1 if int(math.floor((day.toordinal() - 1) / 7) % 2) else 0 week_type = 1 if int(math.floor((day.toordinal() - 1) / 7) % 2) else 0