diff --git a/hr_holidays_usability/__openerp__.py b/hr_holidays_usability/__openerp__.py index 3c9f9d9..a053733 100644 --- a/hr_holidays_usability/__openerp__.py +++ b/hr_holidays_usability/__openerp__.py @@ -35,6 +35,7 @@ 'wizard/hr_holidays_mass_allocation_view.xml', 'hr_holidays_view.xml', 'hr_holidays_mail.xml', + 'res_company_view.xml', ], 'installable': True, } diff --git a/hr_holidays_usability/hr_holidays.py b/hr_holidays_usability/hr_holidays.py index 49920f5..8510a22 100644 --- a/hr_holidays_usability/hr_holidays.py +++ b/hr_holidays_usability/hr_holidays.py @@ -343,9 +343,19 @@ class HrHolidays(orm.Model): raise orm.except_orm( _('Warning!'), _('There are not enough %s allocated for ' - 'employee %s (requesting %s but only %s left).') + 'employee %s (requesting %s but only %s ' + 'left).') % (record.holiday_status_id.name, record.employee_id.name, record.number_of_days * -1, leaves_rest)) return True + + +class ResCompany(orm.Model): + _inherit = 'res.company' + + _columns = { + 'mass_allocation_default_holiday_status_id': fields.many2one( + 'hr.holidays.status', 'Default Leave Type for Mass Allocation'), + } diff --git a/hr_holidays_usability/res_company_view.xml b/hr_holidays_usability/res_company_view.xml new file mode 100644 index 0000000..68f6ec1 --- /dev/null +++ b/hr_holidays_usability/res_company_view.xml @@ -0,0 +1,24 @@ + + + + + + + hr_holidays_usability.res.company.form + res.company + + + + + + + + + + + + diff --git a/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py b/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py index 51da5c7..446a932 100644 --- a/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py +++ b/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py @@ -32,6 +32,13 @@ class HrHolidaysMassAllocation(orm.TransientModel): def _get_all_employees(self, cr, uid, context=None): return self.pool['hr.employee'].search(cr, uid, [], context=context) + def _get_default_holiday_status(self, cr, uid, context=None): + user = self.pool['res.users'].browse(cr, uid, uid, context=context) + if user.company_id.mass_allocation_default_holiday_status_id: + return user.company_id.mass_allocation_default_holiday_status_id.id + else: + return False + _columns = { 'number_of_days': fields.float('Number of Days', required=True), 'holiday_status_id': fields.many2one( @@ -47,6 +54,7 @@ class HrHolidaysMassAllocation(orm.TransientModel): 'number_of_days': 2.08, 'employee_ids': _get_all_employees, 'auto_approve': True, + 'holiday_status_id': _get_default_holiday_status, } _sql_constraints = [(