mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Added new accrue_max field to hr_holidays_accrual and hr_holidays_accrual_payroll.
This commit is contained in:
@@ -5,8 +5,10 @@
|
||||
<field name="model">hr.holidays</field>
|
||||
<field name="inherit_id" ref="hr_holidays.edit_holiday_new"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='category_id']" position="after">
|
||||
<field name="grant_by_tag" attrs="{'invisible': [('holiday_type', '=', 'employee')]}"/>
|
||||
<xpath expr="//group/group[2]" position="after">
|
||||
<group name="accrue" attrs="{'invisible': [('type', '!=', 'add')]}">
|
||||
<field name="grant_by_tag" attrs="{'invisible': [('holiday_type', '=', 'employee')]}"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
'name': 'HR Holidays Accrual - Payroll',
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'version': '11.0.0.0.0',
|
||||
'version': '11.0.1.0.0',
|
||||
'category': 'Human Resources',
|
||||
'sequence': 95,
|
||||
'summary': 'Grant leave allocations per payperiod',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
<field name="model">hr.holidays</field>
|
||||
<field name="inherit_id" ref="hr_holidays.edit_holiday_new"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='category_id']" position="after">
|
||||
<xpath expr="//group[@name='accrue']" position="inside">
|
||||
<field name="accrue_by_pay_period"/>
|
||||
<field name="allocation_per_period"/>
|
||||
<field name="accrue_max"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user