~vauxoo/addons-vauxoo/8.0-import_tax_tariff-dev-yani-rev-2

« back to all changes in this revision

Viewing changes to invoice_cancel_islr/model/invoice.py

  • Committer: Jose Antonio
  • Author(s): Vauxoo
  • Date: 2012-04-23 15:42:11 UTC
  • mfrom: (211.1.6 addons-vauxoo)
  • Revision ID: jose@vauxoo.com-20120423154211-dti7wju0z5vcp73a

[MERGE] Merge from trunk added module to invoice cancel with withholding income and islr

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
    _inherit = 'account.invoice'
 
34
 
 
35
    
 
36
    def action_number(self, cr, uid, ids, context=None):
 
37
        '''
 
38
        Modified to witholding vat validate 
 
39
        '''
 
40
        wf_service = netsvc.LocalService("workflow")
 
41
        res = super(account_invoice, self).action_number(cr, uid, ids, context=context)
 
42
        iva_line_obj = self.pool.get('account.wh.iva.line')
 
43
        iva_obj = self.pool.get('account.wh.iva')
 
44
        invo_brw = self.browse(cr,uid,ids,context=context)[0]
 
45
        if invo_brw.cancel_true:
 
46
            if invo_brw.islr_wh_doc_id:
 
47
                wf_service.trg_validate(uid, 'islr.wh.doc',invo_brw.islr_wh_doc_id.id, 'act_progress', cr)
 
48
                wf_service.trg_validate(uid, 'islr.wh.doc',invo_brw.islr_wh_doc_id.id, 'act_done', cr)
 
49
                
 
50
                
 
51
                
 
52
 
 
53
        return res
 
54
    
 
55
    def invoice_cancel(self,cr,uid,ids,context=None):
 
56
        
 
57
        if context is None:
 
58
            context = {}
 
59
        context.update({'islr':True})
 
60
        res = super(account_invoice, self).invoice_cancel(cr, uid, ids, context=context)
 
61
    
 
62
        return res 
 
63
    
 
64
 
 
65
 
 
66
    def check_islr(self, cr, uid, ids, context=None):
 
67
        if context is None:
 
68
            context={}
 
69
        invo_brw = self.browse(cr,uid,ids[0],context=context)
 
70
        if invo_brw.islr_wh_doc_id:
 
71
            return False
 
72
        return True
 
73
 
 
74
 
 
75
 
 
76
 
 
77
account_invoice()
 
78
 
 
79