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

« back to all changes in this revision

Viewing changes to invoice_cancel_iva/model/invoice.py

  • Committer: Jose Antonio
  • Date: 2012-04-22 20:38:11 UTC
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: jose@vauxoo.com-20120422203811-ahks9nmn4pck8bl8

[ADD] Added news modules to cancel invoices with withholding income and vat 

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
import time
 
27
from osv import fields, osv
 
28
import decimal_precision as dp
 
29
from tools.translate import _
 
30
import netsvc
 
31
 
 
32
class account_invoice(osv.osv):
 
33
  
 
34
    _inherit = 'account.invoice'
 
35
 
 
36
    
 
37
    def action_number(self, cr, uid, ids, context=None):
 
38
        '''
 
39
        Modified to witholding vat validate 
 
40
        '''
 
41
        wf_service = netsvc.LocalService("workflow")
 
42
        res = super(account_invoice, self).action_number(cr, uid, ids, context=context)
 
43
        iva_line_obj = self.pool.get('account.wh.iva.line')
 
44
        iva_obj = self.pool.get('account.wh.iva')
 
45
        invo_brw = self.browse(cr,uid,ids,context=context)[0]
 
46
        if invo_brw.cancel_true:
 
47
            print "iva"
 
48
            if invo_brw.wh_iva_id:
 
49
                iva_line_obj.load_taxes(cr, uid, [i.id for i in invo_brw.wh_iva_id.wh_lines], context=context)
 
50
                wf_service.trg_validate(uid, 'account.wh.iva',invo_brw.wh_iva_id.id, 'wh_iva_confirmed', cr)
 
51
                wf_service.trg_validate(uid, 'account.wh.iva',invo_brw.wh_iva_id.id, 'wh_iva_done', cr)
 
52
                
 
53
 
 
54
        return res
 
55
    
 
56
    def invoice_cancel(self,cr,uid,ids,context=None):
 
57
        
 
58
        if context is None:
 
59
            context = {}
 
60
            
 
61
        res = super(account_invoice, self).invoice_cancel(cr, uid, ids, context=context)
 
62
        
 
63
        return res 
 
64
    
 
65
    def check_iva(self, cr, uid, ids, context=None):
 
66
        if context is None:
 
67
            context={}
 
68
        invo_brw = self.browse(cr,uid,ids[0],context=context)
 
69
        if invo_brw.wh_iva_id:
 
70
            return False
 
71
        return True
 
72
 
 
73
account_invoice()
 
74
 
 
75