diff --git a/account_cancel_invoice_check_voucher/__init__.py b/account_cancel_invoice_check_voucher/__init__.py index 765843d26..7be6ed351 100644 --- a/account_cancel_invoice_check_voucher/__init__.py +++ b/account_cancel_invoice_check_voucher/__init__.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) -# All Right Reserved -# -# Author : Vincent Renaville (Camptocamp) +# Author Vincent Renaville. Copyright 2012 Camptocamp SA # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -20,6 +17,7 @@ # along with this program. If not, see . # ############################################################################## -import account_invoice + +from . import account_invoice # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_cancel_invoice_check_voucher/__openerp__.py b/account_cancel_invoice_check_voucher/__openerp__.py index d9c4d9615..2bab98b5d 100644 --- a/account_cancel_invoice_check_voucher/__openerp__.py +++ b/account_cancel_invoice_check_voucher/__openerp__.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com) -# All Right Reserved -# -# Author : Vincent Renaville (Camptocamp) +# Author Vincent Renaville. Copyright 2012 Camptocamp SA # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -24,14 +21,11 @@ "name" : "Cancel invoice, check on bank statement", "version" : "1.0", "depends" : ["base", "account","account_voucher","account_cancel"], - "author" : "CamptoCamp", + "author" : "Camptocamp", "description": """Contraint to not be able to cancel an invoice already import in bank statement with a voucher """, 'website': 'http://www.camptocamp.com', - 'init_xml': [], - 'update_xml': [ - ], - 'demo_xml': [], + 'date' : [], 'installable': True, 'active': False, } diff --git a/account_cancel_invoice_check_voucher/account_invoice.py b/account_cancel_invoice_check_voucher/account_invoice.py index 23ba03a2c..fa4c8fefc 100644 --- a/account_cancel_invoice_check_voucher/account_invoice.py +++ b/account_cancel_invoice_check_voucher/account_invoice.py @@ -21,32 +21,32 @@ # ############################################################################## -from tools.translate import _ -from osv import osv -from openerp.osv.orm import TransientModel +from openerp.tools.translate import _ +from openerp.osv import osv, orm -class account_invoice(TransientModel): +class account_invoice(orm.TransientModel): _inherit = "account.invoice" def action_cancel(self, cr, uid, ids, *args): - ### invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids']) for i in invoices: if i['move_id']: - ## This invoice have a move line, we search move_line converned by this move - cr.execute("""select (select name from account_bank_statement where id = statement_id) as statement_name, - ((select date from account_bank_statement where id = statement_id)) as statement_date, - name from account_bank_statement_line where voucher_id in - ( select voucher_id from account_voucher_line where move_line_id in ( - select id from account_move_line where move_id = %s ))""", (i['move_id'][0],)) - statement_lines = cr.dictfetchall() + ## This invoice have a move line, we search move_line concerned by this move + cr.execute("""SELECT abs.name as statement_name, + abs.date as statement_date, + absl.name + FROM account_bank_statement_line as absl + INNER JOIN account_bank_statement as abs + ON absl.statement_id = abs.id + WHERE voucher_id in + ( SELECT voucher_id FROM account_voucher_line WHERE move_line_id in + (SELECT id FROM account_move_line WHERE move_id = %s )) limit 1""", (i['move_id'][0],)) + statement_lines = cr.dictfetchone() if statement_lines: raise osv.except_osv(_('Error !'), _('Invoice already import in bank statment (%s) at %s on line %s' - % (statement_lines[0]['statement_name'], - statement_lines[0]['statement_date'], - statement_lines[0]['name'],))) + % (statement_lines['statement_name'], + statement_lines['statement_date'], + statement_lines['name'],))) - - - return super(account_invoice,self).action_cancel(cr, uid, ids, *args) + return super(account_invoice,self).action_cancel(cr, uid, ids, *args) \ No newline at end of file