[FIX] hr_luncheon_voucher: only consider employee's meetings

This commit is contained in:
Stéphan Sainléger
2023-02-06 23:23:09 +01:00
parent dbfa5624a3
commit b08119cf4e
2 changed files with 7 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
{ {
"name": "HR Luncheon Voucher", "name": "HR Luncheon Voucher",
"category": "Human Resources", "category": "Human Resources",
"version": "14.0.2.0.0", "version": "14.0.2.0.1",
"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/",

View File

@@ -98,7 +98,12 @@ class LuncheonVouchersAllocation(models.Model):
def _has_cancelling_voucher_event(self, day): def _has_cancelling_voucher_event(self, day):
category_no_voucher_ids = self.env["calendar.event.type"].search([("remove_luncheon_voucher", "=", True)]) category_no_voucher_ids = self.env["calendar.event.type"].search([("remove_luncheon_voucher", "=", True)])
events = self.env["calendar.event"].search([("categ_ids", "in", category_no_voucher_ids.ids)]) events = self.env["calendar.event"].search(
[
("categ_ids", "in", category_no_voucher_ids.ids),
("partner_ids", "in", self.employee_id.user_id.partner_id.id)
]
)
day_start = fields.Datetime.to_datetime(day.date()) day_start = fields.Datetime.to_datetime(day.date())
day_end = fields.Datetime.to_datetime(day.date()) + timedelta(hours=24) day_end = fields.Datetime.to_datetime(day.date()) + timedelta(hours=24)
cancelling_events = events.filtered(lambda x: not((x.start < day_start) and (x.stop <= day_start)) and not((x.start >= day_end) and (x.stop > day_end)) ) cancelling_events = events.filtered(lambda x: not((x.start < day_start) and (x.stop <= day_start)) and not((x.start >= day_end) and (x.stop > day_end)) )