2010-04-20 05:31:42 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
2010-10-15 13:35:22 +00:00
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import osv
|
|
|
|
from openerp.tools.translate import _
|
2010-04-20 05:31:42 +00:00
|
|
|
|
|
|
|
class account_invoice_confirm(osv.osv_memory):
|
|
|
|
"""
|
|
|
|
This wizard will confirm the all the selected draft invoices
|
|
|
|
"""
|
|
|
|
|
|
|
|
_name = "account.invoice.confirm"
|
|
|
|
_description = "Confirm the selected invoices"
|
|
|
|
|
|
|
|
def invoice_confirm(self, cr, uid, ids, context=None):
|
|
|
|
if context is None:
|
|
|
|
context = {}
|
2013-03-27 13:43:37 +00:00
|
|
|
account_invoice_obj = self.pool['account.invoice']
|
2013-02-01 07:18:33 +00:00
|
|
|
data_inv = account_invoice_obj.read(cr, uid, context['active_ids'], ['state'], context=context)
|
2010-05-05 07:09:55 +00:00
|
|
|
for record in data_inv:
|
|
|
|
if record['state'] not in ('draft','proforma','proforma2'):
|
2012-08-06 15:44:10 +00:00
|
|
|
raise osv.except_osv(_('Warning!'), _("Selected invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state."))
|
2013-02-01 07:18:33 +00:00
|
|
|
account_invoice_obj.signal_invoice_open(cr, uid, [ record['id'] ])
|
|
|
|
|
2010-12-28 10:44:45 +00:00
|
|
|
return {'type': 'ir.actions.act_window_close'}
|
2010-04-20 05:31:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
class account_invoice_cancel(osv.osv_memory):
|
|
|
|
"""
|
|
|
|
This wizard will cancel the all the selected invoices.
|
|
|
|
If in the journal, the option allow cancelling entry is not selected then it will give warning message.
|
|
|
|
"""
|
|
|
|
|
|
|
|
_name = "account.invoice.cancel"
|
2010-05-05 07:09:55 +00:00
|
|
|
_description = "Cancel the Selected Invoices"
|
2010-04-20 05:31:42 +00:00
|
|
|
|
|
|
|
def invoice_cancel(self, cr, uid, ids, context=None):
|
|
|
|
if context is None:
|
|
|
|
context = {}
|
2013-03-27 13:43:37 +00:00
|
|
|
account_invoice_obj = self.pool['account.invoice']
|
2013-02-01 07:18:33 +00:00
|
|
|
data_inv = account_invoice_obj.read(cr, uid, context['active_ids'], ['state'], context=context)
|
2010-05-05 07:09:55 +00:00
|
|
|
for record in data_inv:
|
|
|
|
if record['state'] in ('cancel','paid'):
|
2012-08-06 15:44:10 +00:00
|
|
|
raise osv.except_osv(_('Warning!'), _("Selected invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state."))
|
2013-02-01 07:18:33 +00:00
|
|
|
account_invoice_obj.signal_invoice_cancel(cr , uid, [record['id']])
|
2010-12-28 10:44:45 +00:00
|
|
|
return {'type': 'ir.actions.act_window_close'}
|
2010-04-20 05:31:42 +00:00
|
|
|
|
|
|
|
|
2012-03-05 17:41:11 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|