~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: Nhomar Hernandez
  • Date: 2013-04-19 20:33:12 UTC
  • mfrom: (542.1.314 addons-vauxoo)
  • Revision ID: nhomar@gmail.com-20130419203312-o35v7dn79l6vur0t
[MERGE - PEP8 AND V7-MIG] All migrated to V7 Just
improved osv.osv => osv.Model, osv.osv_memory => osv.TransientModel
import inside openerp.* enviroment
Erased class instansiation no necesarry anymore in V7
AUTOPEP8 run, Left PEP8 long lines manually.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#    Module Writen to OpenERP, Open Source Management Solution
5
5
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
6
6
#    All Rights Reserved
7
 
###############Credits######################################################
8
 
#    Coded by: Vauxoo C.A.           
 
7
# Credits######################################################
 
8
#    Coded by: Vauxoo C.A.
9
9
#    Planified by: Nhomar Hernandez
10
10
#    Audited by: Vauxoo C.A.
11
11
#############################################################################
21
21
#
22
22
#    You should have received a copy of the GNU Affero General Public License
23
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 
################################################################################
 
24
##########################################################################
25
25
 
26
26
import time
27
 
from osv import fields, osv
 
27
from openerp.osv import osv, fields
28
28
import decimal_precision as dp
29
 
from tools.translate import _
30
 
import netsvc
31
 
 
32
 
class account_invoice(osv.osv):
 
29
from openerp.tools.translate import _
 
30
 
 
31
import openerp.netsvc as netsvc
 
32
 
 
33
 
 
34
class account_invoice(osv.Model):
33
35
    _inherit = 'account.invoice'
34
36
 
35
 
    #~ 
 
37
    #~
36
38
    #~ def action_cancel_draft(self, cr, uid, ids, *args):
37
 
        #~ 
 
39
        #~
38
40
        #~ wf_service = netsvc.LocalService("workflow")
39
41
        #~ res = super(account_invoice, self).action_cancel_draft(cr, uid, ids, ())
40
42
        #~ for i in self.browse(cr,uid,ids,context={}):
42
44
                #~ wf_service.trg_validate(uid, 'islr.wh.doc',i.islr_wh_doc_id.id, 'act_draft', cr)
43
45
        #~ return res
44
46
 
45
 
 
46
 
 
47
 
 
48
47
    def action_number(self, cr, uid, ids, context=None):
49
48
        '''
50
 
        Modified to witholding vat validate 
 
49
        Modified to witholding vat validate
51
50
        '''
52
51
        wf_service = netsvc.LocalService("workflow")
53
52
        res = super(account_invoice, self).action_number(cr, uid, ids)
54
53
        iva_line_obj = self.pool.get('account.wh.iva.line')
55
54
        iva_obj = self.pool.get('account.wh.iva')
56
 
        invo_brw = self.browse(cr,uid,ids,context=context)[0]
57
 
        state = [('draft','act_draft'),('progress','act_progress'),('confirmed','act_confirmed'),('done','act_done')]
 
55
        invo_brw = self.browse(cr, uid, ids, context=context)[0]
 
56
        state = [('draft', 'act_draft'), ('progress', 'act_progress'), (
 
57
            'confirmed', 'act_confirmed'), ('done', 'act_done')]
58
58
        if invo_brw.cancel_true:
59
59
            if invo_brw.islr_wh_doc_id:
60
60
                for i in state:
61
 
                    
 
61
 
62
62
                    if invo_brw.islr_wh_doc_id.prev_state == 'cancel':
63
63
                        break
64
 
                    
65
 
                    wf_service.trg_validate(uid, 'islr.wh.doc',invo_brw.islr_wh_doc_id.id, i[1] , cr)
66
 
                    
 
64
 
 
65
                    wf_service.trg_validate(
 
66
                        uid, 'islr.wh.doc', invo_brw.islr_wh_doc_id.id, i[1], cr)
 
67
 
67
68
                    if i[0] == invo_brw.islr_wh_doc_id.prev_state:
68
69
                        break
69
70
 
70
71
        return res
71
 
    
72
 
    def invoice_cancel(self,cr,uid,ids,context=None):
73
 
        
 
72
 
 
73
    def invoice_cancel(self, cr, uid, ids, context=None):
 
74
 
74
75
        if context is None:
75
76
            context = {}
76
77
        islr_obj = self.pool.get('islr.wh.doc')
77
 
        context.update({'islr':True})
78
 
        invo_brw = self.browse(cr,uid,ids,context=context)[0]
 
78
        context.update({'islr': True})
 
79
        invo_brw = self.browse(cr, uid, ids, context=context)[0]
79
80
        if invo_brw.islr_wh_doc_id:
80
 
             islr_obj.write(cr,uid,[invo_brw.islr_wh_doc_id.id],{'prev_state':invo_brw.islr_wh_doc_id.state},context=context)
81
 
        res = super(account_invoice, self).invoice_cancel(cr, uid, ids, context=context)
82
 
    
83
 
        return res 
84
 
    
 
81
            islr_obj.write(cr, uid, [invo_brw.islr_wh_doc_id.id], {
 
82
                           'prev_state': invo_brw.islr_wh_doc_id.state}, context=context)
 
83
        res = super(account_invoice, self).invoice_cancel(
 
84
            cr, uid, ids, context=context)
85
85
 
 
86
        return res
86
87
 
87
88
    def check_islr(self, cr, uid, ids, context=None):
88
89
        if context is None:
89
 
            context={}
90
 
        invo_brw = self.browse(cr,uid,ids[0],context=context)
 
90
            context = {}
 
91
        invo_brw = self.browse(cr, uid, ids[0], context=context)
91
92
        if invo_brw.islr_wh_doc_id:
92
93
            return False
93
94
        return True
94
95
 
95
96
 
96
 
 
97
 
 
98
 
account_invoice()
99
 
 
100