1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com)
7
# Author : Vincent Renaville (Camptocamp)
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU Affero General Public License as
11
# published by the Free Software Foundation, either version 3 of the
12
# License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU Affero General Public License for more details.
19
# You should have received a copy of the GNU Affero General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
24
from tools.translate import _
26
from openerp.osv.orm import TransientModel
28
class account_invoice(TransientModel):
29
_inherit = "account.invoice"
31
def action_cancel(self, cr, uid, ids, *args):
33
invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
36
## This invoice have a move line, we search move_line converned by this move
37
cr.execute("""select (select name from account_bank_statement where id = statement_id) as statement_name,
38
((select date from account_bank_statement where id = statement_id)) as statement_date,
39
name from account_bank_statement_line where voucher_id in
40
( select voucher_id from account_voucher_line where move_line_id in (
41
select id from account_move_line where move_id = %s ))""", (i['move_id'][0],))
42
statement_lines = cr.dictfetchall()
44
raise osv.except_osv(_('Error !'),
45
_('Invoice already import in bank statment (%s) at %s on line %s'
46
% (statement_lines[0]['statement_name'],
47
statement_lines[0]['statement_date'],
48
statement_lines[0]['name'],)))
52
return super(account_invoice,self).action_cancel(cr, uid, ids, *args)