~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to invoice_cancel_islr/model/invoice.py

  • Committer: Gabriela (Vauxoo)
  • Date: 2012-01-02 16:24:49 UTC
  • Revision ID: gabrielaquilarque97@gmail.com-20120102162449-lhxnrtif2ud36du2

[ADD] Added new module invoice_so.

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 openerp.osv import osv, fields
28
 
import decimal_precision as dp
29
 
from openerp.tools.translate import _
30
 
 
31
 
import openerp.netsvc as netsvc
32
 
 
33
 
 
34
 
class account_invoice(osv.Model):
35
 
    _inherit = 'account.invoice'
36
 
 
37
 
    #~
38
 
    #~ def action_cancel_draft(self, cr, uid, ids, *args):
39
 
        #~
40
 
        #~ wf_service = netsvc.LocalService("workflow")
41
 
        #~ res = super(account_invoice, self).action_cancel_draft(cr, uid, ids, ())
42
 
        #~ for i in self.browse(cr,uid,ids,context={}):
43
 
            #~ if i.islr_wh_doc_id:
44
 
                #~ wf_service.trg_validate(uid, 'islr.wh.doc',i.islr_wh_doc_id.id, 'act_draft', cr)
45
 
        #~ return res
46
 
 
47
 
    def action_number(self, cr, uid, ids, context=None):
48
 
        '''
49
 
        Modified to witholding vat validate
50
 
        '''
51
 
        wf_service = netsvc.LocalService("workflow")
52
 
        res = super(account_invoice, self).action_number(cr, uid, ids)
53
 
        iva_line_obj = self.pool.get('account.wh.iva.line')
54
 
        iva_obj = self.pool.get('account.wh.iva')
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
 
        if invo_brw.cancel_true:
59
 
            if invo_brw.islr_wh_doc_id:
60
 
                for i in state:
61
 
 
62
 
                    if invo_brw.islr_wh_doc_id.prev_state == 'cancel':
63
 
                        break
64
 
 
65
 
                    wf_service.trg_validate(
66
 
                        uid, 'islr.wh.doc', invo_brw.islr_wh_doc_id.id, i[1],
67
 
                        cr)
68
 
 
69
 
                    if i[0] == invo_brw.islr_wh_doc_id.prev_state:
70
 
                        break
71
 
 
72
 
        return res
73
 
 
74
 
    def invoice_cancel(self, cr, uid, ids, context=None):
75
 
 
76
 
        if context is None:
77
 
            context = {}
78
 
        islr_obj = self.pool.get('islr.wh.doc')
79
 
        context.update({'islr': True})
80
 
        invo_brw = self.browse(cr, uid, ids, context=context)[0]
81
 
        if invo_brw.islr_wh_doc_id:
82
 
            islr_obj.write(cr, uid, [invo_brw.islr_wh_doc_id.id], {
83
 
                           'prev_state': invo_brw.islr_wh_doc_id.state},
84
 
                            context=context)
85
 
        res = super(account_invoice, self).invoice_cancel(
86
 
            cr, uid, ids, context=context)
87
 
 
88
 
        return res
89
 
 
90
 
    def check_islr(self, cr, uid, ids, context=None):
91
 
        if context is None:
92
 
            context = {}
93
 
        invo_brw = self.browse(cr, uid, ids[0], context=context)
94
 
        if invo_brw.islr_wh_doc_id:
95
 
            return False
96
 
        return True