~openerp-spain-team/openerp-spain/6.0-git

« back to all changes in this revision

Viewing changes to l10n_es_extras/l10n_ES_hr_nominas/wizard/wizard_crea_nominas.py

  • Committer: Borja L.S.
  • Date: 2010-10-18 10:04:25 UTC
  • Revision ID: git-v1:271c47a993616dbba60585d48b8b98d603199d93
[REF] *: Refactorización para portar a 6.0 - Paso 1.

- Se han renombrado los módulos para usar la nomenclatura propuesta
  por OpenERP: l10n_es para el módulo base de localización (plan de 
  cuentas), l10n_es_* para el resto de módulos.

- Se eliminan los módulos extra_addons/* que deberían moverse a 
  los extra-addons genéricos (no son específicos de España).

- Se renombran los __terp__.py por __openerp__.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- encoding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6
 
#    $Id$
7
 
#
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.
12
 
#
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.
17
 
#
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/>.
20
 
#
21
 
##############################################################################
22
 
import wizard
23
 
import time
24
 
import datetime
25
 
import pooler
26
 
 
27
 
form = """<?xml version="1.0"?>
28
 
<form string="Generar Nominas">
29
 
    <field name="fecha"/>
30
 
    <field name="employee_ids" colspan="4" height="320" width="780"/>
31
 
</form>"""
32
 
 
33
 
fields = {
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]))},
36
 
 
37
 
}
38
 
 
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']
43
 
        return data['form']
44
 
 
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})
50
 
 
51
 
    states = {
52
 
        'init': {
53
 
            'actions': [_get_defaults],
54
 
            'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Cancelar','gtk-no'),('crear_nominas','Crear Nóminas','gtk-yes')]}
55
 
        },
56
 
        'crear_nominas': {
57
 
            'actions': [],
58
 
            'result': {'type':'action', 'action':_crea_nominas, 'state':'end'}
59
 
        }
60
 
    }
61
 
crea_nominas('wiz_crear_nominas')
62
 
 
63
 
 
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']
68
 
        return data['form']
69
 
 
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})
75
 
 
76
 
    states = {
77
 
        'init': {
78
 
            'actions': [_get_defaults],
79
 
            'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Cancelar','gtk-no'),('crear_anticipos','Crear Pagas Extra','gtk-yes')]}
80
 
        },
81
 
        'crear_anticipos': {
82
 
            'actions': [],
83
 
            'result': {'type':'action', 'action':_crea_extras, 'state':'end'}
84
 
        }
85
 
    }
86
 
crea_extras('wiz_crear_extras')
87
 
 
88
 
 
89
 
form_anticipos = """<?xml version="1.0"?>
90
 
<form string="Generar Anticipo">
91
 
    <field name="fecha"/>
92
 
    <field name="employee_ids" colspan="4" height="320" width="800"/>
93
 
    <field name="cantidad"/>
94
 
</form>"""
95
 
 
96
 
fields_anticipos = {
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}
100
 
}
101
 
 
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']
106
 
        return data['form']
107
 
 
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']})
113
 
 
114
 
    states = {
115
 
        'init': {
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')]}
118
 
        },
119
 
        'crear_anticipos': {
120
 
            'actions': [],
121
 
            'result': {'type':'action', 'action':_crea_anticipos, 'state':'end'}
122
 
        }
123
 
    }
124
 
crea_anticipos('wiz_crear_anticipos')
125