~vauxoo/addons-vauxoo/7.0-add_project_followers_rule-dev-ernesto

« back to all changes in this revision

Viewing changes to change_invoice_number/wizard/change_number.py

  • Committer: Jose Antonio
  • Date: 2012-05-03 16:07:48 UTC
  • mto: This revision was merged to the branch mainline in revision 229.
  • Revision ID: jose@vauxoo.com-20120503160748-ij3lna0514jhokx1

[ADD] Module change_invoice_number added, This module allows number invoice change after this is validate

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: Vauxoo C.A.           
 
9
#    Planified by: Nhomar Hernandez
 
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 fields, osv
 
27
import tools
 
28
from tools.translate import _
 
29
from tools import config
 
30
import netsvc
 
31
import decimal_precision as dp
 
32
import time
 
33
 
 
34
 
 
35
class change_number(osv.osv_memory):
 
36
 
 
37
    
 
38
    _name = 'change.number'
 
39
    _columns = {
 
40
        'number':fields.char('New Number',20,help="Enter the new number of the invoice"),
 
41
        'sure':fields.boolean('Are sure?',help="Select to number change"),
 
42
        
 
43
    }
 
44
    
 
45
    def change_number(self,cr,uid,ids,context=None):
 
46
        if context is None:
 
47
            context = {}
 
48
        invo_obj = self.pool.get('account.invoice')
 
49
        move_obj = self.pool.get('account.move')
 
50
        if context.get('active_id'):
 
51
            wzr_brw = self.browse(cr,uid,ids,context=context)[0]
 
52
            if wzr_brw.sure:
 
53
                invo_brw = invo_obj.browse(cr,uid,context.get('active_id'),context=context)
 
54
                invo_brw.move_id and move_obj.write(cr,uid,[invo_brw.move_id.id],{'name':wzr_brw.number},context=context)
 
55
                invo_obj.write(cr,uid,[invo_brw.id],{'internal_number':wzr_brw.number},context=context)
 
56
            else:
 
57
                raise osv.except_osv(_('Invalid action !'),_("Must be sure the operation"))
 
58
        return {'type': 'ir.actions.act_window_close'}
 
59
 
 
60
 
 
61
change_number()
 
62