diff options
| author | qdp-launchpad@tinyerp.com <> | 2010-03-17 18:09:26 +0100 |
|---|---|---|
| committer | qdp-launchpad@tinyerp.com <> | 2010-03-17 18:09:26 +0100 |
| commit | e328055359259bb9ea676dec3d7e0c2155ebe061 (patch) | |
| tree | 6161834e3931a9f32d4ba130816e4ac7a200cf39 /addons | |
| parent | 062fc996a4c54f4bef3f3bb3d2fbf1e3652bbcfc (diff) | |
[IMP] hr_holidays: improvements
bzr revid: qdp-launchpad@tinyerp.com-20100317170926-zyw5frdscx3kpi1p
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/hr_holidays/__terp__.py | 3 | ||||
| -rwxr-xr-x | addons/hr_holidays/hr.py | 131 | ||||
| -rw-r--r-- | addons/hr_holidays/hr_holidays_report.xml | 71 | ||||
| -rw-r--r-- | addons/hr_holidays/hr_holidays_wizard.xml | 7 | ||||
| -rw-r--r-- | addons/hr_holidays/hr_view.xml | 99 | ||||
| -rw-r--r-- | addons/hr_holidays/report/__init__.py | 6 | ||||
| -rw-r--r-- | addons/hr_holidays/report/available_holidays.py | 33 | ||||
| -rw-r--r-- | addons/hr_holidays/report/holidays_summary_report.py | 1 | ||||
| -rw-r--r-- | addons/hr_holidays/security/ir.model.access.csv | 8 |
9 files changed, 187 insertions, 172 deletions
diff --git a/addons/hr_holidays/__terp__.py b/addons/hr_holidays/__terp__.py index f44fe590015..26dc78675cc 100644 --- a/addons/hr_holidays/__terp__.py +++ b/addons/hr_holidays/__terp__.py @@ -53,9 +53,8 @@ 'security/ir.model.access.csv', 'hr_workflow.xml', 'hr_view.xml', - 'hr_holidays_report.xml', 'hr_holidays_wizard.xml', - 'report/hr_holidays_report_view.xml', + 'hr_holidays_report.xml', #'process/hr_holidays_process.xml' ], 'demo_xml': [], diff --git a/addons/hr_holidays/hr.py b/addons/hr_holidays/hr.py index b6c0313e13f..12cb02f659f 100755 --- a/addons/hr_holidays/hr.py +++ b/addons/hr_holidays/hr.py @@ -37,17 +37,13 @@ class hr_holidays_status(osv.osv): for record in self.browse(cr, uid, ids, context): res[record.id] = {} max_leaves = leaves_taken = 0 - obj_ids = self.pool.get('hr.holidays.per.user').search(cr, uid, [('user_id','=',uid),('employee_id','=',employee_id),('holiday_status','=',record.id)]) - if obj_ids: - br_ob=self.pool.get('hr.holidays.per.user').browse(cr, uid, obj_ids)[0] - max_leaves=br_ob.max_leaves if not return_false: cr.execute("""SELECT type, sum(number_of_days) FROM hr_holidays WHERE employee_id = %s AND state='validate' AND holiday_status_id = %s GROUP BY type""", (str(employee_id), str(record.id))) for line in cr.fetchall(): if line[0] =='remove': - leaves_taken = -line[1] + leaves_taken = -line[1] if line[0] =='add': - max_leaves = line[1] + max_leaves = line[1] res[record.id]['max_leaves'] = max_leaves res[record.id]['leaves_taken'] = leaves_taken res[record.id]['remaining_leaves'] = max_leaves - leaves_taken @@ -66,18 +62,19 @@ class hr_holidays_status(osv.osv): employee_id = employee_ids[0] else: return_false = True - res = self.get_days(cr, uid, ids, employee_id, return_false, context=context) + if employee_id: + res = self.get_days(cr, uid, ids, employee_id, return_false, context=context) return res _columns = { 'name' : fields.char('Name', size=64, required=True, translate=True), - 'section_id': fields.many2one('crm.case.section', 'CRM Section', help='If you link this type of leave with a section in the CRM, it will synchronize each leave asked with a case in this section, to display it in the company shared calendar for example.'), + 'categ_id': fields.many2one('crm.case.categ', 'Meeting Category', domain="[('object_id.model', '=', 'crm.meeting')]", help='If you link this type of leave with a category in the CRM, it will synchronize each leave asked with a case in this category, to display it in the company shared calendar for example.'), 'color_name' : fields.selection([('red', 'Red'), ('lightgreen', 'Light Green'), ('lightblue','Light Blue'), ('lightyellow', 'Light Yellow'), ('magenta', 'Magenta'),('lightcyan', 'Light Cyan'),('black', 'Black'),('lightpink', 'Light Pink'),('brown', 'Brown'),('violet', 'Violet'),('lightcoral', 'Light Coral'),('lightsalmon', 'Light Salmon'),('lavender', 'Lavender'),('wheat', 'Wheat'),('ivory', 'Ivory')],'Color of the status', required=True, help='This color will be used in the leaves summary located in Reporting\Print Summary of Leaves'), 'limit' : fields.boolean('Allow to override Limit', help='If you thick this checkbox, the system will allow, for this section, the employees to take more leaves than the available ones.'), - 'active' : fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the leave type without removing it."), + 'active' : fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the leave type without removing it."), 'max_leaves' : fields.function(_user_left_days, method=True, string='Maximum Leaves Allowed', help='This value is given by the sum of all holidays requests with a positive value.', multi='user_left_days'), 'leaves_taken' : fields.function(_user_left_days, method=True, string='Leaves Already Taken', help='This value is given by the sum of all holidays requests with a negative value.', multi='user_left_days'), - 'remaining_leaves' : fields.function(_user_left_days, method=True, string='Remaining Leaves', multi='user_left_days'), + 'remaining_leaves' : fields.function(_user_left_days, method=True, string='Remaining Leaves', help='Maximum Leaves Allowed - Leaves Already Taken', multi='user_left_days'), } _defaults = { @@ -86,48 +83,6 @@ class hr_holidays_status(osv.osv): } hr_holidays_status() -class hr_holidays_per_user(osv.osv): - _name = "hr.holidays.per.user" - _description = "Holidays Per User" - _rec_name = "user_id" - - def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}): - obj_holiday = self.pool.get('hr.holidays') - result = {} - for holiday_user in self.browse(cr, uid, ids): - days = 0.0 - ids_request = obj_holiday.search(cr, uid, [('employee_id', '=', holiday_user.employee_id.id),('state', '=', 'validate'),('holiday_status_id', '=', holiday_user.holiday_status.id)]) - if ids_request: - holidays = obj_holiday.browse(cr, uid, ids_request) - for holiday in holidays: - days -= holiday.number_of_days - days = holiday_user.max_leaves - days - result[holiday_user.id] = days - return result - - _columns = { - 'employee_id': fields.many2one('hr.employee', "Employee's Name",required=True), - 'user_id' : fields.many2one('res.users','User'), - 'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True), - 'max_leaves' : fields.float('Maximum Leaves Allowed',required=True), - 'leaves_taken' : fields.float('Leaves Already Taken',readonly=True), - 'active' : fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the holidays per user without removing it."), - 'notes' : fields.text('Notes'), - 'remaining_leaves': fields.function(_get_remaining_leaves, method=True, string='Remaining Leaves', type='float'), - 'holiday_ids': fields.one2many('hr.holidays', 'holiday_user_id', 'Holidays') - } - _defaults = { - 'active' : lambda *a: True, - } - - def create(self, cr, uid, vals, *args, **kwargs): - if vals['employee_id']: - obj_emp=self.pool.get('hr.employee').browse(cr,uid,vals['employee_id']) - vals.update({'user_id': obj_emp.user_id.id}) - return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs) - -hr_holidays_per_user() - class hr_holidays(osv.osv): _name = "hr.holidays" _description = "Holidays" @@ -152,13 +107,12 @@ class hr_holidays(osv.osv): 'notes' : fields.text('Notes',readonly=True, states={'draft':[('readonly',False)]}), 'number_of_days': fields.float('Number of Days', readonly=True, states={'draft':[('readonly',False)]}), 'number_of_days_temp': fields.float('Number of Days', readonly=True, states={'draft':[('readonly',False)]}), - 'case_id': fields.many2one('crm.case', 'Case'), + 'case_id': fields.many2one('crm.meeting', 'Case'), 'type': fields.selection([('remove','Leave Request'),('add','Allocation Request')], 'Request Type', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="Choose 'Leave Request' if someone wants to take an off-day. \nChoose 'Allocation Request' if you want to increase the number of leaves available for someone"), 'allocation_type': fields.selection([('employee','Employee Request'),('company','Company Allocation')], 'Allocation Type', required=True, readonly=True, states={'draft':[('readonly',False)]}, help='This field is only for informative purposes, to depict if the leave request/allocation comes from an employee or from the company'), 'parent_id': fields.many2one('hr.holidays', 'Parent'), 'linked_request_ids': fields.one2many('hr.holidays', 'parent_id', 'Linked Requests',), - 'holiday_user_id' : fields.many2one('hr.holidays.per.user', 'User'), - 'department_id':fields.many2one('hr.department','Department'), + 'department_id':fields.many2one('hr.department','Department', readonly=True, states={'draft':[('readonly',False)]} ), } _defaults = { @@ -170,6 +124,14 @@ class hr_holidays(osv.osv): } _order = 'date_from desc' + def create(self, cr, uid, vals, context={}): + if context: + if context.has_key('type'): + vals['type'] = context['type'] + if context.has_key('allocation_type'): + vals['allocation_type'] = context['allocation_type'] + return super(osv.osv,self).create(cr, uid, vals, context) + def onchange_date_from(self, cr, uid, ids, date_to, date_from): result = {} if date_to and date_from: @@ -188,16 +150,14 @@ class hr_holidays(osv.osv): def _update_user_holidays(self, cr, uid, ids): for record in self.browse(cr, uid, ids): if record.state=='validate': - holiday_id=self.pool.get('hr.holidays.per.user').search(cr, uid, [('employee_id','=', record.employee_id.id),('holiday_status','=',record.holiday_status_id.id)]) - if holiday_id: - obj_holidays_per_user=self.pool.get('hr.holidays.per.user').browse(cr, uid,holiday_id[0]) - self.pool.get('hr.holidays.per.user').write(cr,uid,obj_holidays_per_user.id,{'leaves_taken':obj_holidays_per_user.leaves_taken - record.number_of_days}) if record.case_id: - if record.case_id.state <> 'draft': - raise osv.except_osv(_('Warning !'), - _('You can not cancel this holiday request. first You have to make its case in draft state.')) - else: - self.pool.get('crm.case').unlink(cr,uid,[record.case_id.id]) + self.pool.get('crm.meeting').unlink(cr,uid,[record.case_id.id]) + if record.linked_request_ids: + list_ids = [] + for id in record.linked_request_ids: + list_ids.append(id.id) + self.holidays_cancel(cr,uid,list_ids) + self.unlink(cr,uid,list_ids) def _check_date(self, cr, uid, ids): if ids: @@ -209,26 +169,11 @@ class hr_holidays(osv.osv): _constraints = [(_check_date, 'Start date should not be larger than end date! ', ['number_of_days'])] - def create(self, cr, uid, vals, *args, **kwargs): - id_holiday = super(hr_holidays, self).create(cr, uid, vals, *args, **kwargs) - self._create_holiday(cr, uid, [id_holiday]) - return id_holiday def unlink(self, cr, uid, ids, context={}): self._update_user_holidays(cr, uid, ids) return super(hr_holidays, self).unlink(cr, uid, ids, context) - def _create_holiday(self, cr, uid, ids): - holidays_user_obj = self.pool.get('hr.holidays.per.user') - holidays_data = self.browse(cr, uid, ids[0]) - list_holiday = [] - ids_user_hdays = holidays_user_obj.search(cr, uid, [('employee_id', '=', holidays_data.employee_id.id),('holiday_status', '=', holidays_data.holiday_status_id.id)]) - for hdays in holidays_user_obj.browse(cr, uid, ids_user_hdays): - for req in hdays.holiday_ids: - list_holiday.append(req.id) - list_holiday.append(ids[0]) - holidays_user_obj.write(cr, uid, ids_user_hdays, {'holiday_ids': [(6, 0, list_holiday)]}) - return True def onchange_date_to(self, cr, uid, ids, date_from, date_to): result = {} @@ -249,7 +194,7 @@ class hr_holidays(osv.osv): warning = {} if status: brows_obj = self.pool.get('hr.holidays.status').browse(cr, uid, [status])[0] - if brows_obj.section_id and not brows_obj.section_id.allow_unlink: + if brows_obj.categ_id and brows_obj.categ_id.section_id and not brows_obj.categ_id.section_id.allow_unlink: warning = { 'title': "Warning for ", 'message': "You won\'t be able to cancel this leave request because the CRM Section of the leave type disallows." @@ -283,6 +228,7 @@ class hr_holidays(osv.osv): def holidays_confirm(self, cr, uid, ids, *args): for record in self.browse(cr, uid, ids): + user_id = False leave_asked = record.number_of_days_temp if record.type == 'remove': if record.employee_id and not record.holiday_status_id.limit: @@ -300,14 +246,14 @@ class hr_holidays(osv.osv): 'number_of_days': nb, 'user_id': user_id }) - vals= { - 'name':record.name, - 'date_from':record.date_from, - 'date_to':record.date_to, - 'calendar_id':record.employee_id.calendar_id.id, - 'company_id':record.employee_id.company_id.id, - 'resource_id':record.employee_id.resource_id.id - } + #vals= { + # 'name':record.name, + # 'date_from':record.date_from, + # 'date_to':record.date_to, + # 'calendar_id':record.employee_id.calendar_id.id, + # 'company_id':record.employee_id.company_id.id, + # 'resource_id':record.employee_id.resource_id.id + # } #self.pool.get('resource.calendar.leaves').create(cr,uid,vals) return True @@ -365,14 +311,17 @@ class hr_holidays(osv.osv): employee_ids = self.pool.get('hr.employee').search(cr, uid, []) for employee in employee_ids: vals['employee_id'] = employee + user_id = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)]) + if user_id: + vals['user_id'] = user_id[0] holiday_ids.append(self.create(cr, uid, vals, context={})) self.holidays_confirm(cr, uid, holiday_ids) self.holidays_validate(cr, uid, holiday_ids) - if record.holiday_status_id.section_id and record.date_from and record.date_to and record.employee_id: + if record.holiday_status_id.categ_id and record.date_from and record.date_to and record.employee_id: vals={} vals['name']=record.name - vals['section_id']=record.holiday_status_id.section_id.id + vals['categ_id']=record.holiday_status_id.categ_id.id epoch_c = time.mktime(time.strptime(record.date_to,'%Y-%m-%d %H:%M:%S')) epoch_d = time.mktime(time.strptime(record.date_from,'%Y-%m-%d %H:%M:%S')) diff_day = (epoch_c - epoch_d)/(3600*24) @@ -380,7 +329,7 @@ class hr_holidays(osv.osv): vals['note'] = record.notes vals['user_id'] = record.user_id.id vals['date'] = record.date_from - case_id = self.pool.get('crm.case').create(cr,uid,vals) + case_id = self.pool.get('crm.meeting').create(cr,uid,vals) self.write(cr, uid, ids, {'case_id':case_id}) return True hr_holidays() diff --git a/addons/hr_holidays/hr_holidays_report.xml b/addons/hr_holidays/hr_holidays_report.xml index 23d1e1a75bf..66669bd2f51 100644 --- a/addons/hr_holidays/hr_holidays_report.xml +++ b/addons/hr_holidays/hr_holidays_report.xml @@ -9,6 +9,77 @@ auto="False" menu="False"/> + + + +<!-- available holidays report --> + + <record id="view_report_hr_holiday_tree" model="ir.ui.view"> + <field name="name">hr.holidays.report.tree</field> + <field name="model">hr.holidays.report</field> + <field name="type">tree</field> + <field name="arch" type="xml"> + <tree string="Available Holidays"> + <field name="employee_id"/> + <field name="holiday_status_id"/> + <field name="remaining_leave"/> + </tree> + </field> + </record> + + <record id="view_report_hr_holiday_form" model="ir.ui.view"> + <field name="name">hr.holidays.report.form</field> + <field name="model">hr.holidays.report</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <tree string="Available Holidays"> + <field name="employee_id" select="1"/> + <field name="holiday_status_id" select="1"/> + <field name="remaining_leave"/> + </tree> + </field> + </record> + <record id="view_report_hr_holiday_graph" model="ir.ui.view"> + <field name="name">hr.holiday.report.graph</field> + <field name="model">hr.holidays.report</field> + <field name="type">graph</field> + <field name="arch" type="xml"> + <graph orientation="horizontal" string="Available Holidays" type="bar"> + <field name="holiday_status_id"/> + <field name="remaining_leave" operator="+"/> + <field group="True" name="employee_id"/> + </graph> + </field> + </record> + + <record id="action_report_hr_holiday" model="ir.actions.act_window"> + <field name="name">Available Holidays</field> + <field name="res_model">hr.holidays.report</field> + <field name="view_type">form</field> + <field name="view_mode">tree,graph</field> + <field name="view_id" ref="view_report_hr_holiday_tree"/> + + </record> + + <record model="ir.actions.act_window.view" id="action_report_hr_holiday_tree"> + <field name="sequence" eval="1"/> + <field name="view_mode">tree</field> + <field name="view_id" ref="view_report_hr_holiday_tree"/> + <field name="act_window_id" ref="action_report_hr_holiday"/> + </record> + + + <record model="ir.actions.act_window.view" id="action_report_hr_holiday_graph"> + <field name="sequence" eval="2"/> + <field name="view_mode">graph</field> + <field name="view_id" ref="view_report_hr_holiday_graph"/> + <field name="act_window_id" ref="action_report_hr_holiday"/> + </record> + + + <menuitem name="Available Holidays" id="menu_report_hr_holiday_tree" action="action_report_hr_holiday" parent="menu_hr_reporting_holidays"/> + + </data> </openerp> diff --git a/addons/hr_holidays/hr_holidays_wizard.xml b/addons/hr_holidays/hr_holidays_wizard.xml index fb505d65497..fc433a181e7 100644 --- a/addons/hr_holidays/hr_holidays_wizard.xml +++ b/addons/hr_holidays/hr_holidays_wizard.xml @@ -11,10 +11,11 @@ name="Holidays" parent="hr.menu_hr_reporting" sequence="3" /> - <wizard string="Print Summary of Holidays" + <wizard string="Holidays by Departement" name="hr.holidays.summary" id="holidays_summary"/> - <menuitem name="Print Summary of Holidays" parent="menu_hr_reporting_holidays" + <menuitem name="Holidays by Departement" parent="menu_hr_reporting_holidays" + icon="STOCK_PRINT" action="holidays_summary" type="wizard" id="menu_holidays_summary" sequence="20"/> @@ -24,7 +25,7 @@ <field eval="[(6,0,[ref('hr.group_hr_manager')])]" name="groups_id"/> </record> - <wizard string="Print Summary of Employee's Holidays" + <wizard string="Employee's Holidays" model="hr.employee" name="hr.holidays.summary.employee" keyword="client_print_multi" id="wizard_holidays_summary" /> </data> diff --git a/addons/hr_holidays/hr_view.xml b/addons/hr_holidays/hr_view.xml index 146e06d25a3..d46898bd6bb 100644 --- a/addons/hr_holidays/hr_view.xml +++ b/addons/hr_holidays/hr_view.xml @@ -1,13 +1,6 @@ <?xml version="1.0" ?> <openerp> <data> - <!--<menuitem - id="menu_hr_reporting" - name="Reporting" - parent="hr.menu_hr_root" - sequence="40" />--> - <!-- Menu Items --> - <record id="view_hr_holidays_filter" model="ir.ui.view"> <field name="name">hr.holidays.filter</field> <field name="model">hr.holidays</field> @@ -38,7 +31,6 @@ <!-- Holidays: Leave Request --> - <record model="ir.ui.view" id="edit_holiday_new"> <field name="name">Leave Request</field> <field name="model">hr.holidays</field> @@ -73,7 +65,6 @@ </record> <!-- Holidays: Allocation Request --> - <record model="ir.ui.view" id="allocation_leave_new"> <field name="name">Allocation Request</field> <field name="model">hr.holidays</field> @@ -104,18 +95,17 @@ </field> </record> - <!-- Holidays: Company Allocation --> - + <!-- Holidays: Leaves Management --> <record model="ir.ui.view" id="allocation_company_new"> - <field name="name">Company Allocation</field> + <field name="name">Leaves Management</field> <field name="model">hr.holidays</field> <field name="type">form</field> <field name="arch" type="xml"> - <form string="Company Allocation"> + <form string="Leaves Management"> <field name="name" select="1"/> <field name="holiday_status_id" select="1"/> <field name="employee_id" select="1" /> - <field name="department_id"/> + <!--<field name="department_id"/>--> <field name="type"/> <field name="date_from" select="1" on_change="onchange_date_from(date_to, date_from)" attrs="{'readonly':[('type','=','add')], 'required':[('type','=','remove')]}"/> <field name="date_to" select="1" on_change="onchange_date_to(date_from, date_to)" attrs="{'readonly':[('type','=','add')], 'required':[('type','=','remove')]}"/> @@ -153,13 +143,13 @@ <field name="date_to"/> <field name="holiday_status_id"/> <field name="state"/> -<!-- <field name="type"/>--> + <field name="type"/> </tree> </field> </record> <!-- My leave dashboard --> - <record model="ir.ui.view" id="view_my_leave_board_form"> +<!-- <record model="ir.ui.view" id="view_my_leave_board_form"> <field name="name">hr.holidays.per.user.form</field> <field name="model">hr.holidays.per.user</field> <field name="type">form</field> @@ -175,33 +165,12 @@ </form> </field> </record> - - <record model="ir.ui.view" id="view_my_leave_board_tree"> - <field name="name">hr.holidays.per.user.tree</field> - <field name="model">hr.holidays.per.user</field> - <field name="type">tree</field> - <field name="arch" type="xml"> - <tree string="My Leaves" editable="top"> - <tree string="My Leaves" /> - <field name="employee_id"/> - <field name="user_id"/> - <field name="holiday_status"/> - <field name="max_leaves"/> - <field name="leaves_taken" /> - <field name="remaining_leaves"/> - <field name="notes"/> - </tree> - </field> - </record> - - <!-- <menuitem - name="Holidays Management" - parent="hr.menu_hr_root" - id="menu_open_ask_holidays"/>--> - <menuitem - name="Leaves" sequence="7" +--> + <menuitem + name="Holidays Management" parent="hr.menu_hr_root" id="menu_open_ask_holidays"/> + <record model="ir.actions.act_window" id="open_ask_holidays"> <field name="name">Leave Request(s)</field> <field name="res_model">hr.holidays</field> @@ -226,13 +195,8 @@ </record> - <!-- <menuitem - name="Holidays Requests" - parent="menu_open_ask_holidays" - id="menu_open_ask_holidays_new" - action="open_ask_holidays"/>--> <menuitem - name="Leaves Requests" + name="Leave Requests" parent="menu_open_ask_holidays" id="menu_open_ask_holidays_new" action="open_ask_holidays"/> @@ -256,16 +220,32 @@ <record model="ir.actions.act_window.view" id="action_open_allocation_holidays_form"> <field name="sequence" eval="2"/> <field name="view_mode">form</field> - <field name="view_id" ref="allocation_company_new"/> + <field name="view_id" ref="allocation_leave_new"/> <field name="act_window_id" ref="open_allocation_holidays"/> </record> - <!-- <menuitem + <menuitem name="Allocation Requests" parent="menu_open_ask_holidays" id="menu_open_allocation_holidays" - action="open_allocation_holidays"/>--> + action="open_allocation_holidays"/> + + <record model="ir.actions.act_window" id="open_company_allocation"> + <field name="res_model">hr.holidays</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="allocation_company_new" /> + <field name="context">{'allocation_type':'company'}</field> + </record> + + <menuitem + name="Leaves Management" + parent="menu_open_ask_holidays" + id="menu_open_company_allocation" + action="open_company_allocation" + groups="hr.group_hr_manager" + sequence="40"/> <!-- holidays status --> <record model="ir.ui.view" id="edit_holiday_status_form"> @@ -276,7 +256,7 @@ <form string="Leave Type"> <field colspan="4" name="name" select="1"/> <field name="color_name" select="2"/> - <field name="section_id" select="1" widget="selection"/> + <field name="categ_id" select="1" widget="selection"/> <field name="limit" select="2"/> <field name="active" select="2"/> </form> @@ -303,10 +283,6 @@ </record> <menuitem sequence="9" id="hr.menu_open_view_attendance_reason_config" parent="hr.menu_hr_configuration" name="Leaves"/> - <!--<menuitem - action="open_view_holiday_status" - id="menu_open_view_holiday_status" - parent="hr.menu_hr_configuration"/>--> <menuitem name="Leaves Statuses" action="open_view_holiday_status" id="menu_open_view_holiday_status" @@ -320,18 +296,5 @@ view_id ="eval('edit_holiday_new')" id="act_hr_employee_holiday_request"/> - <record model="ir.actions.act_window" id="action_holiday_per_user"> - <field name="name">Holiday Per User</field> - <field name="res_model">hr.holidays.per.user</field> - <field name="view_type">form</field> - <field name="view_mode">tree,form</field> - <field name="view_id" ref="view_my_leave_board_tree"/> - </record> - - <menuitem name="Holiday Per User" - action="action_holiday_per_user" - id="menu_holiday_per_user" - parent="hr.menu_open_view_attendance_reason_config"/> - </data> </openerp> diff --git a/addons/hr_holidays/report/__init__.py b/addons/hr_holidays/report/__init__.py index bb1f6229bc0..00783721fe3 100644 --- a/addons/hr_holidays/report/__init__.py +++ b/addons/hr_holidays/report/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,11 +15,11 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import holidays_summary_report -import hr_holidays_report +import available_holidays # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_holidays/report/available_holidays.py b/addons/hr_holidays/report/available_holidays.py new file mode 100644 index 00000000000..259aea0dec9 --- /dev/null +++ b/addons/hr_holidays/report/available_holidays.py @@ -0,0 +1,33 @@ +from osv import fields,osv +import tools + +class hr_holidays_report(osv.osv): + _name = "hr.holidays.report" + _auto = False + _columns = { + 'employee_id': fields.many2one ('hr.employee', 'Employee', readonly=True), + 'holiday_status_id': fields.many2one('hr.holidays.status', 'Leave Type', readonly=True), + # 'max_leave': fields.float('Allocated Leaves', readonly=True), +# 'taken_leaves': fields.float('Taken Leaves', readonly=True), + 'remaining_leave': fields.float('Remaining Leaves',readonly=True), + } + def init(self, cr): + tools.drop_view_if_exists(cr, 'hr_holidays_report') + cr.execute(""" + create or replace view hr_holidays_report as ( + select + min(h.id) as id, + h.employee_id as employee_id, + h.holiday_status_id as holiday_status_id, + sum(number_of_days) as remaining_leave + from + hr_holidays h + left join hr_holidays_status s on (s.id = h.holiday_status_id) + where h.state = 'validate' + and h.employee_id is not null + and s.active <> 'f' + group by h.holiday_status_id, h.employee_id + )""") +hr_holidays_report() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py index e0cb697b3b9..c61e8f733b4 100644 --- a/addons/hr_holidays/report/holidays_summary_report.py +++ b/addons/hr_holidays/report/holidays_summary_report.py @@ -44,7 +44,6 @@ def strToDate(dt): def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom): display={} - if dept==0: count=0 p_id=pooler.get_pool(cr.dbname).get('hr.holidays').search(cr,uid,[('employee_id','in',[empid,False]), ('type', '=', 'remove')]) diff --git a/addons/hr_holidays/security/ir.model.access.csv b/addons/hr_holidays/security/ir.model.access.csv index 236b6a8fb89..a7426724594 100644 --- a/addons/hr_holidays/security/ir.model.access.csv +++ b/addons/hr_holidays/security/ir.model.access.csv @@ -1,5 +1,5 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_hr_holydays_status_user","hr.holidays.status user","model_hr_holidays_status","hr.group_hr_user",1,1,1,1 -"access_hr_holidays_user","hr holidays user","model_hr_holidays","hr.group_hr_user",1,1,1,1 -"access_hr_holidays_per_user","hr.holidays.per.user","model_hr_holidays_per_user","hr.group_hr_user",1,1,1,1 -"access_hr_holidays_report","hr.holidays.report","model_hr_holidays_report","hr.group_hr_user",1,1,1,1 +"access_hr_holydays_status_user","hr.holidays.status user","model_hr_holidays_status","hr.group_hr_user",1,0,0,0 +"access_hr_holidays_user","hr holidays user","model_hr_holidays","hr.group_hr_user",1,1,1,0 +"access_hr_holydays_status_manager","hr.holidays.status manager","model_hr_holidays_status","hr.group_hr_manager",1,1,1,1 +"access_hr_holidays_manager","hr holidays manager","model_hr_holidays","hr.group_hr_manager",1,1,1,1 |
