Add default value for mass allocation wizard
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
'wizard/hr_holidays_mass_allocation_view.xml',
|
'wizard/hr_holidays_mass_allocation_view.xml',
|
||||||
'hr_holidays_view.xml',
|
'hr_holidays_view.xml',
|
||||||
'hr_holidays_mail.xml',
|
'hr_holidays_mail.xml',
|
||||||
|
'res_company_view.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,9 +343,19 @@ class HrHolidays(orm.Model):
|
|||||||
raise orm.except_orm(
|
raise orm.except_orm(
|
||||||
_('Warning!'),
|
_('Warning!'),
|
||||||
_('There are not enough %s allocated for '
|
_('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.holiday_status_id.name,
|
||||||
record.employee_id.name,
|
record.employee_id.name,
|
||||||
record.number_of_days * -1,
|
record.number_of_days * -1,
|
||||||
leaves_rest))
|
leaves_rest))
|
||||||
return True
|
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'),
|
||||||
|
}
|
||||||
|
|||||||
24
hr_holidays_usability/res_company_view.xml
Normal file
24
hr_holidays_usability/res_company_view.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
The licence is in the file __openerp__.py
|
||||||
|
-->
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record id="view_company_form" model="ir.ui.view">
|
||||||
|
<field name="name">hr_holidays_usability.res.company.form</field>
|
||||||
|
<field name="model">res.company</field>
|
||||||
|
<field name="inherit_id" ref="base.view_company_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<group name="account_grp" position="after">
|
||||||
|
<group string="Leaves" name="holidays">
|
||||||
|
<field name="mass_allocation_default_holiday_status_id"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
@@ -32,6 +32,13 @@ class HrHolidaysMassAllocation(orm.TransientModel):
|
|||||||
def _get_all_employees(self, cr, uid, context=None):
|
def _get_all_employees(self, cr, uid, context=None):
|
||||||
return self.pool['hr.employee'].search(cr, uid, [], context=context)
|
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 = {
|
_columns = {
|
||||||
'number_of_days': fields.float('Number of Days', required=True),
|
'number_of_days': fields.float('Number of Days', required=True),
|
||||||
'holiday_status_id': fields.many2one(
|
'holiday_status_id': fields.many2one(
|
||||||
@@ -47,6 +54,7 @@ class HrHolidaysMassAllocation(orm.TransientModel):
|
|||||||
'number_of_days': 2.08,
|
'number_of_days': 2.08,
|
||||||
'employee_ids': _get_all_employees,
|
'employee_ids': _get_all_employees,
|
||||||
'auto_approve': True,
|
'auto_approve': True,
|
||||||
|
'holiday_status_id': _get_default_holiday_status,
|
||||||
}
|
}
|
||||||
|
|
||||||
_sql_constraints = [(
|
_sql_constraints = [(
|
||||||
|
|||||||
Reference in New Issue
Block a user