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

« back to all changes in this revision

Viewing changes to l10n_es_hr_nominas/wizard/wizard_pagar_anticipos.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_pagar = """<?xml version="1.0"?>
 
28
<form string="Pagar Anticipos">
 
29
   <field name="anticipos_ids" height="320" width="780" domain="[('state','=','confirmado')]"/>
 
30
</form>"""
 
31
 
 
32
form_confirmar = """<?xml version="1.0"?>
 
33
<form string="Confirmar Anticipos">
 
34
   <field name="anticipos_ids" height="320" width="780" domain="[('state','=','borrador')]"/>
 
35
</form>"""
 
36
 
 
37
fields = {
 
38
    'anticipos_ids': {'string': 'Anticipos', 'type': 'many2many', 'relation': 'hr.anticipo', 'required': True},
 
39
}
 
40
 
 
41
class wizard_pagar_anticipo(wizard.interface):
 
42
    def _get_defaults(self, cr, uid, data, context={}):
 
43
        if data['model'] == 'hr.anticipo':
 
44
            data['form']['anticipos_ids'] = data['ids']
 
45
        return data['form']
 
46
 
 
47
    def _pagar_anticipos(self, cr, uid, data, context):
 
48
        pool = pooler.get_pool(cr.dbname)
 
49
        for ant_id in data['form']['anticipos_ids'][0][2]:
 
50
            anticipo = pool.get('hr.anticipo').browse(cr, uid, ant_id)
 
51
            anticipo.pagar_anticipo(self, cr, uid, ant_id)
 
52
 
 
53
    states = {
 
54
        'init': {
 
55
            'actions': [_get_defaults],
 
56
            'result': {'type':'form', 'arch':form_pagar, 'fields':fields, 'state':[('end','Cancelar','gtk-no'),('pagar_anticipos','Pagar','gtk-yes')]}
 
57
        },
 
58
        'pagar_anticipos': {
 
59
            'actions': [],
 
60
            'result': {'type':'action', 'action':_pagar_anticipos, 'state':'end'}
 
61
        }
 
62
    }
 
63
wizard_pagar_anticipo('wizard_pagar_anticipos')
 
64
 
 
65
 
 
66
class wizard_confirmar_anticipo(wizard.interface):
 
67
    def _get_defaults(self, cr, uid, data, context={}):
 
68
        if data['model'] == 'hr.anticipo':
 
69
            data['form']['anticipos_ids'] = data['ids']
 
70
        return data['form']
 
71
 
 
72
    def _confirmar_anticipos(self, cr, uid, data, context):
 
73
        pool = pooler.get_pool(cr.dbname)
 
74
        for ant_id in data['form']['anticipos_ids'][0][2]:
 
75
            anticipo = pool.get('hr.anticipo').browse(cr, uid, ant_id)
 
76
            anticipo.confirmar_anticipo(self, cr, uid, ant_id)
 
77
 
 
78
    states = {
 
79
        'init': {
 
80
            'actions': [_get_defaults],
 
81
            'result': {'type':'form', 'arch':form_confirmar, 'fields':fields, 'state':[('end','Cancelar','gtk-no'),('confirmar_anticipos','confirmar','gtk-yes')]}
 
82
        },
 
83
        'confirmar_anticipos': {
 
84
            'actions': [],
 
85
            'result': {'type':'action', 'action':_confirmar_anticipos, 'state':'end'}
 
86
        }
 
87
    }
 
88
wizard_confirmar_anticipo('wizard_confirmar_anticipos')