1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
27
form = """<?xml version="1.0"?>
28
<form string="Generar Nominas">
30
<field name="employee_ids" colspan="4" height="320" width="780"/>
34
'employee_ids': {'string': 'Empleados', 'type': 'many2many', 'relation': 'hr.employee', 'required': True},
35
'fecha': {'string': 'Fecha Nómina', 'type': 'date', 'required': True, 'default': lambda *a: time.strftime('%Y-%m-' + str([31,28,31,30,31,30,31,31,30,31,30,31][time.localtime()[1]-1]))},
39
class crea_nominas(wizard.interface):
40
def _get_defaults(self, cr, uid, data, context={}):
41
if data['model'] == 'hr.employee':
42
data['form']['employee_ids'] = data['ids']
45
def _crea_nominas(self, cr, uid, data, context):
46
pool = pooler.get_pool(cr.dbname)
47
for emp_id in data['form']['employee_ids'][0][2]:
48
empleado = pool.get('hr.employee').browse(cr, uid, emp_id)
49
pool.get('hr.nomina').create(cr, uid, {'employee_id': empleado.id, 'fecha_nomina': data['form']['fecha'], 'retribucion_bruta': empleado.retribucion_bruta, 'ss_empresa': empleado.ss_empresa, 'ss_trabajador': empleado.ss_trabajador, 'irpf': empleado.irpf})
53
'actions': [_get_defaults],
54
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Cancelar','gtk-no'),('crear_nominas','Crear Nóminas','gtk-yes')]}
58
'result': {'type':'action', 'action':_crea_nominas, 'state':'end'}
61
crea_nominas('wiz_crear_nominas')
64
class crea_extras(wizard.interface):
65
def _get_defaults(self, cr, uid, data, context={}):
66
if data['model'] == 'hr.employee':
67
data['form']['employee_ids'] = data['ids']
70
def _crea_extras(self, cr, uid, data, context):
71
pool = pooler.get_pool(cr.dbname)
72
for emp_id in data['form']['employee_ids'][0][2]:
73
empleado = pool.get('hr.employee').browse(cr, uid, emp_id)
74
pool.get('hr.nomina').create(cr, uid, {'name': empleado.name + ' ' + str(data['form']['fecha']),'employee_id': empleado.id, 'fecha_nomina': data['form']['fecha'], 'retribucion_bruta': empleado.retribucion_bruta_extra, 'ss_empresa': empleado.ss_empresa_extra, 'ss_trabajador': empleado.ss_trabajador_extra, 'irpf': empleado.irpf_extra, 'extra': True})
78
'actions': [_get_defaults],
79
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Cancelar','gtk-no'),('crear_anticipos','Crear Pagas Extra','gtk-yes')]}
83
'result': {'type':'action', 'action':_crea_extras, 'state':'end'}
86
crea_extras('wiz_crear_extras')
89
form_anticipos = """<?xml version="1.0"?>
90
<form string="Generar Anticipo">
92
<field name="employee_ids" colspan="4" height="320" width="800"/>
93
<field name="cantidad"/>
97
'employee_ids': {'string': 'Empleados', 'type': 'many2many', 'relation': 'hr.employee', 'required': True},
98
'fecha': {'string': 'Fecha Anticipo', 'type': 'date', 'required': True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
99
'cantidad': {'string': 'Cantidad Anticipo', 'type': 'float', 'required': True}
102
class crea_anticipos(wizard.interface):
103
def _get_defaults(self, cr, uid, data, context={}):
104
if data['model'] == 'hr.employee':
105
data['form']['employee_ids'] = data['ids']
108
def _crea_anticipos(self, cr, uid, data, context):
109
pool = pooler.get_pool(cr.dbname)
110
for emp_id in data['form']['employee_ids'][0][2]:
111
empleado = pool.get('hr.employee').browse(cr, uid, emp_id)
112
pool.get('hr.anticipo').create(cr, uid, {'employee_id': empleado.id, 'fecha_anticipo': data['form']['fecha'], 'cantidad': data['form']['cantidad']})
116
'actions': [_get_defaults],
117
'result': {'type':'form', 'arch':form_anticipos, 'fields':fields_anticipos, 'state':[('end','Cancelar','gtk-no'),('crear_anticipos','Crear Anticipos','gtk-yes')]}
121
'result': {'type':'action', 'action':_crea_anticipos, 'state':'end'}
124
crea_anticipos('wiz_crear_anticipos')