Initial commit: Hr packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:50 +02:00
commit 62531cd146
2820 changed files with 1432848 additions and 0 deletions

View file

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import hr_holidays_cancel_leave
from . import hr_holidays_summary_employees
from . import hr_departure_wizard

View file

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from datetime import datetime, timedelta
from odoo import api, fields, models
class HrDepartureWizard(models.TransientModel):
_inherit = 'hr.departure.wizard'
cancel_leaves = fields.Boolean("Cancel Future Leaves", default=True,
help="Cancel all time off after this date.")
archive_allocation = fields.Boolean("Archive Employee Allocations", default=True,
help="Remove employee from existing accrual plans.")
def action_register_departure(self):
super(HrDepartureWizard, self).action_register_departure()
if self.cancel_leaves:
future_leaves = self.env['hr.leave'].search([('employee_id', '=', self.employee_id.id),
('date_to', '>', self.departure_date),
('state', '!=', 'refuse')])
future_leaves.action_refuse()
if self.archive_allocation:
employee_allocations = self.env['hr.leave.allocation'].search([('employee_id', '=', self.employee_id.id)])
employee_allocations.action_archive()

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_departure_wizard_view_form" model="ir.ui.view">
<field name="name">hr.departure.wizard.view.form.extend3</field>
<field name="model">hr.departure.wizard</field>
<field name="inherit_id" ref="hr.hr_departure_wizard_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='activities_label']" position="attributes">
<attribute name="invisible">0</attribute>
</xpath>
<xpath expr="//div[@id='activities']" position="attributes">
<attribute name="invisible">0</attribute>
</xpath>
<xpath expr="//div[@id='activities']" position="inside">
<div><field name="cancel_leaves"/><label for="cancel_leaves" string="Time Off"/></div>
<div><field name="archive_allocation"/><label for="archive_allocation" string="Allocations"/></div>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, _
from odoo.exceptions import ValidationError
class HrHolidaysCancelLeave(models.TransientModel):
_name = 'hr.holidays.cancel.leave'
_description = 'Cancel Leave Wizard'
leave_id = fields.Many2one('hr.leave', required=True)
reason = fields.Text(required=True)
def action_cancel_leave(self):
self.ensure_one()
self.leave_id._action_user_cancel(self.reason)
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'type': 'success',
'message': _("Your time off has been canceled."),
'next': {'type': 'ir.actions.act_window_close'},
}
}

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_holidays_cancel_leave_form" model="ir.ui.view">
<field name="model">hr.holidays.cancel.leave</field>
<field name="arch" type="xml">
<form string="Cancel Time Off">
<group>
<field name="leave_id" invisible="1" />
<field name="reason" placeholder="Provide a reason for cancellation of an approved time off" />
</group>
<footer>
<button name="action_cancel_leave" type="object" class="btn-primary" string="Delete Time Off" />
<button special="cancel" string="Discard" close="1" />
</footer>
</form>
</field>
</record>
</odoo>

View file

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import time
from odoo import api, fields, models
class HolidaysSummaryEmployee(models.TransientModel):
_name = 'hr.holidays.summary.employee'
_description = 'HR Time Off Summary Report By Employee'
date_from = fields.Date(string='From', required=True, default=lambda *a: time.strftime('%Y-%m-01'))
emp = fields.Many2many('hr.employee', 'summary_emp_rel', 'sum_id', 'emp_id', string='Employee(s)')
holiday_type = fields.Selection([
('Approved', 'Approved'),
('Confirmed', 'Confirmed'),
('both', 'Both Approved and Confirmed')
], string='Select Time Off Type', required=True, default='Approved')
def print_report(self):
self.ensure_one()
[data] = self.read()
data['emp'] = self.env.context.get('active_ids', [])
employees = self.env['hr.employee'].browse(data['emp'])
datas = {
'ids': [],
'model': 'hr.employee',
'form': data
}
return self.env.ref('hr_holidays.action_report_holidayssummary').report_action(employees, data=datas)

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_hr_holidays_summary_employee" model="ir.ui.view">
<field name="name">hr.holidays.summary.employee.form</field>
<field name="model">hr.holidays.summary.employee</field>
<field name="arch" type="xml">
<form string="Time Off Summary">
<group col="4" colspan="6">
<field name="date_from"/>
<newline/>
<field name="holiday_type"/>
<newline/>
<field name="emp" invisible="True"/>
</group>
<footer>
<button name="print_report" string="Print" type="object" class="btn-primary" data-hotkey="q"/>
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="z" />
</footer>
</form>
</field>
</record>
<record id="action_hr_holidays_summary_employee" model="ir.actions.act_window">
<field name="name">Time Off Summary</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.holidays.summary.employee</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="hr.model_hr_employee" />
<field name="binding_type">report</field>
</record>
</odoo>