From f2777c403b76ed39495d042e0e5f6c8456a70919 Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Wed, 18 Sep 2013 09:14:16 +0200 Subject: [PATCH] [FIX] code cleaning --- account_credit_control/invoice.py | 34 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/account_credit_control/invoice.py b/account_credit_control/invoice.py index dfba47a7d..6a9ec38b4 100644 --- a/account_credit_control/invoice.py +++ b/account_credit_control/invoice.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Nicolas Bessi, Guewen Baconnier, Vincent Renaville -# Copyright 2012 Camptocamp SA +# Author: Vincent Renaville +# Copyright 2013 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 @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## -from openerp.osv import orm, osv, fields +from openerp.osv import orm, fields from openerp.tools.translate import _ @@ -30,12 +30,26 @@ class AccountInvoice(orm.Model): # We will search if this invoice is linked with credit credit_control_line_obj = self.pool.get('credit.control.line') for invoice_id in ids: - credit_control_line_ids_nondraft = credit_control_line_obj.search(cr, uid, [('invoice_id','=',invoice_id),('state','<>','draft')]) + credit_control_line_ids_nondraft = credit_control_line_obj.search(cr, + uid, + [('invoice_id', '=', invoice_id), + ('state', '<>', 'draft')]) if credit_control_line_ids_nondraft: - raise osv.except_osv(_('Error!'), _('You cannot cancel this invoice ! ' - 'A payment reminder has already been sent to the customer.' - 'You must create a credit note and raise a new invoice.')) - credit_control_line_ids_draft = credit_control_line_obj.search(cr, uid, [('invoice_id','=',invoice_id),('state','=','draft')]) + raise orm.except_orm(_('Error!'), + _('You cannot cancel this invoice ! ' + 'A payment reminder has already been ' + 'sent to the customer.' + 'You must create a credit note and raise a new invoice.')) + credit_control_line_ids_draft = credit_control_line_obj.search(cr, + uid, + [('invoice_id', '=', invoice_id), + ('state', '=', 'draft')]) if credit_control_line_ids_draft: - credit_control_line_obj.unlink(cr,uid,credit_control_line_ids_draft,context=context) - return super(AccountInvoice,self).action_cancel(cr, uid, ids, context=context) + credit_control_line_obj.unlink(cr, + uid, + credit_control_line_ids_draft, + context=context) + return super(AccountInvoice, self).action_cancel(cr, + uid, + ids, + context=context)