diff --git a/hr_holidays_accrual/views/hr_holidays_views.xml b/hr_holidays_accrual/views/hr_holidays_views.xml
index 7ca7bad6..a2cbed87 100644
--- a/hr_holidays_accrual/views/hr_holidays_views.xml
+++ b/hr_holidays_accrual/views/hr_holidays_views.xml
@@ -5,8 +5,10 @@
hr.holidays
-
-
+
+
+
+
diff --git a/hr_holidays_accrual_payroll/__manifest__.py b/hr_holidays_accrual_payroll/__manifest__.py
index 061f4429..96893f7f 100755
--- a/hr_holidays_accrual_payroll/__manifest__.py
+++ b/hr_holidays_accrual_payroll/__manifest__.py
@@ -1,7 +1,7 @@
{
'name': 'HR Holidays Accrual - Payroll',
'author': 'Hibou Corp. ',
- 'version': '11.0.0.0.0',
+ 'version': '11.0.1.0.0',
'category': 'Human Resources',
'sequence': 95,
'summary': 'Grant leave allocations per payperiod',
diff --git a/hr_holidays_accrual_payroll/models/hr_payslip.py b/hr_holidays_accrual_payroll/models/hr_payslip.py
index 893be350..1c47b6a4 100644
--- a/hr_holidays_accrual_payroll/models/hr_payslip.py
+++ b/hr_holidays_accrual_payroll/models/hr_payslip.py
@@ -13,7 +13,20 @@ class HRPayslip(models.Model):
('accrue_by_pay_period', '=', True)])
for leave_to_update in leaves_to_update:
new_allocation = leave_to_update.number_of_days_temp + leave_to_update.allocation_per_period
- leave_to_update.write({'number_of_days_temp': new_allocation})
+ q = """SELECT SUM(number_of_days)
+ FROM hr_holidays
+ WHERE employee_id = %d AND holiday_status_id = %d;""" % (leave_to_update.employee_id.id, leave_to_update.holiday_status_id.id)
+ self.env.cr.execute(q)
+ total_days = self.env.cr.fetchall()
+ total_days = total_days[0][0]
+ new_total_days = total_days + leave_to_update.allocation_per_period
+ if leave_to_update.accrue_max and total_days > leave_to_update.accrue_max:
+ new_allocation = leave_to_update.number_of_days_temp
+ elif leave_to_update.accrue_max and new_total_days > leave_to_update.accrue_max:
+ difference = leave_to_update.accrue_max - total_days
+ new_allocation = leave_to_update.number_of_days_temp + difference
+ if leave_to_update.number_of_days_temp != new_allocation:
+ leave_to_update.write({'number_of_days_temp': new_allocation})
return res
@@ -23,10 +36,12 @@ class HRHolidays(models.Model):
accrue_by_pay_period = fields.Boolean(string="Accrue by Pay Period")
allocation_per_period = fields.Float(string="Allocation Per Pay Period", digits=(12, 4))
+ accrue_max = fields.Float(string="Maximum Accrual")
def _accrue_for_employee_values(self, employee):
values = super(HRHolidays, self)._accrue_for_employee_values(employee)
if values:
values['accrue_by_pay_period'] = self.accrue_by_pay_period
values['allocation_per_period'] = self.allocation_per_period
+ values['accrue_max'] = self.accrue_max
return values
diff --git a/hr_holidays_accrual_payroll/views/hr_holidays_views.xml b/hr_holidays_accrual_payroll/views/hr_holidays_views.xml
index 8c15f42c..a10a06fe 100644
--- a/hr_holidays_accrual_payroll/views/hr_holidays_views.xml
+++ b/hr_holidays_accrual_payroll/views/hr_holidays_views.xml
@@ -5,9 +5,10 @@
hr.holidays
-
+
+