~vauxoo/openerp-venezuela-localization/ovl70-whiva-rev2-kty

« back to all changes in this revision

Viewing changes to l10n_ve_fiscal_requirements/wizard/wizard_update_name.py

  • Committer: Humberto Arocha
  • Date: 2013-01-28 13:54:35 UTC
  • mfrom: (764.2.20 ovl70-fr-rev-yani)
  • Revision ID: humbertoarocha@gmail.com-20130128135435-555zqkiykm8wwroe
[MERGE] Added Update Name wizard to Partner

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- encoding: utf-8 -*-
 
3
###########################################################################
 
4
#    Module Writen to OpenERP, Open Source Management Solution
 
5
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
 
6
#    All Rights Reserved
 
7
###############Credits######################################################
 
8
#    Coded by: Yanina Aular <yanina.aular@vauxoo.com>           
 
9
#    Planified by: Humberto Arocha
 
10
#    Audited by: Vauxoo C.A.
 
11
#############################################################################
 
12
#    This program is free software: you can redistribute it and/or modify
 
13
#    it under the terms of the GNU Affero General Public License as published by
 
14
#    the Free Software Foundation, either version 3 of the License, or
 
15
#    (at your option) any later version.
 
16
#
 
17
#    This program is distributed in the hope that it will be useful,
 
18
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
#    GNU Affero General Public License for more details.
 
21
#
 
22
#    You should have received a copy of the GNU Affero General Public License
 
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
################################################################################
 
25
 
 
26
from osv import osv
 
27
from osv import fields
 
28
from tools.translate import _
 
29
 
 
30
class wiz_updatename(osv.osv_memory):
 
31
    _name = 'wiz.updatename'
 
32
    _description = "Wizard that changes the partner name"
 
33
 
 
34
    def set_name(self, cr, uid, ids, context):
 
35
        data = self.pool.get('wiz.updatename').read(cr, uid, ids)[0]
 
36
        print ids
 
37
        if not data['sure']:
 
38
            raise osv.except_osv(_("Error!"), _("Please confirm that you want to do this by checking the option"))
 
39
        
 
40
        partner_obj = self.pool.get('res.partner')
 
41
        name_partner = data['name']
 
42
        
 
43
        partner_obj.write(cr, uid, context['active_id'], {'name': name_partner}, context=context)
 
44
        return {}
 
45
 
 
46
    _columns = {
 
47
        'name': fields.char('Name', 256, required=True),
 
48
        'sure': fields.boolean('Are you sure?'),
 
49
    }
 
50
 
 
51
    def _get_name(self, cr, uid, context=None):
 
52
        if context is None:
 
53
            context = {}
 
54
        partner_obj = self.pool.get('res.partner')
 
55
        partner = partner_obj.search(cr, uid, [('id', '=', context['active_id'])])
 
56
        partner_o = partner_obj.browse(cr, uid,  partner[0])
 
57
        return partner_o and partner_o.name or False
 
58
 
 
59
    _defaults = {
 
60
        'name': _get_name,
 
61
    }
 
62
    
 
63
wiz_updatename()