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
##########################################################################
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 _
32
class account_invoice(osv.osv):
29
from openerp.tools.translate import _
31
import openerp.netsvc as netsvc
34
class account_invoice(osv.Model):
33
35
_inherit = 'account.invoice'
36
38
#~ def action_cancel_draft(self, cr, uid, ids, *args):
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)
48
47
def action_number(self, cr, uid, ids, context=None):
50
Modified to witholding vat validate
49
Modified to witholding vat validate
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:
62
62
if invo_brw.islr_wh_doc_id.prev_state == 'cancel':
65
wf_service.trg_validate(uid, 'islr.wh.doc',invo_brw.islr_wh_doc_id.id, i[1] , cr)
65
wf_service.trg_validate(
66
uid, 'islr.wh.doc', invo_brw.islr_wh_doc_id.id, i[1], cr)
67
68
if i[0] == invo_brw.islr_wh_doc_id.prev_state:
72
def invoice_cancel(self,cr,uid,ids,context=None):
73
def invoice_cancel(self, cr, uid, ids, context=None):
74
75
if context is None:
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)
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)
87
88
def check_islr(self, cr, uid, ids, context=None):
88
89
if context is None:
90
invo_brw = self.browse(cr,uid,ids[0],context=context)
91
invo_brw = self.browse(cr, uid, ids[0], context=context)
91
92
if invo_brw.islr_wh_doc_id: