[FIX] website info view remove optional tag
[odoo/odoo.git] / addons / l10n_in_hr_payroll / wizard / hr_salary_employee_bymonth.py
1 #-*- coding:utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2011 OpenERP SA (<http://openerp.com>). All Rights Reserved
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as published by
9 #    the Free Software Foundation, either version 3 of the License, or
10 #    (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 import time
23 from openerp.osv import fields, osv
24
25 class hr_salary_employee_bymonth(osv.osv_memory):
26
27     _name = 'hr.salary.employee.month'
28     _description = 'Hr Salary Employee By Month Report'
29     _columns = {
30         'start_date': fields.date('Start Date', required=True),
31         'end_date': fields.date('End Date', required=True),
32         'employee_ids': fields.many2many('hr.employee', 'payroll_year_rel', 'payroll_year_id', 'employee_id', 'Employees', required=True),
33         'category_id': fields.many2one('hr.salary.rule.category', 'Category', required=True),
34     }
35
36     def _get_default_category(self, cr, uid, context=None):
37         category_ids = self.pool.get('hr.salary.rule.category').search(cr, uid, [('code', '=', 'NET')], context=context)
38         return category_ids and category_ids[0] or False
39
40     _defaults = {
41          'start_date': lambda *a: time.strftime('%Y-01-01'),
42          'end_date': lambda *a: time.strftime('%Y-%m-%d'),
43          'category_id': _get_default_category
44     }
45
46     def print_report(self, cr, uid, ids, context=None):
47         """
48          To get the date and print the report
49          @param self: The object pointer.
50          @param cr: A database cursor
51          @param uid: ID of the user currently logged in
52          @param context: A standard dictionary
53          @return: return report
54         """
55         if context is None:
56             context = {}
57         datas = {'ids': context.get('active_ids', [])}
58
59         res = self.read(cr, uid, ids, context=context)
60         res = res and res[0] or {}
61         datas.update({'form': res})
62         return self.pool['report'].get_action(cr, uid, ids, 
63                         'l10n_in_hr_payroll.report_hrsalarybymonth', 
64                         data=datas, context=context)
65
66 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: