From fe7dc3d817336c146023fb3b1c8bee25297bbeb7 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Fri, 15 Feb 2013 18:08:42 +0100 Subject: [PATCH 1/2] [IMP] remove useless whitespaces bzr revid: abo@openerp.com-20130215170842-662m14hjbpqelhbu --- addons/account/account_invoice.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index f255b6788ee..933670a1fd0 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -308,7 +308,7 @@ class account_invoice(osv.osv): ''' Find the partner for which the accounting entries will be created ''' - #if the chosen partner is not a company and has a parent company, use the parent for the journal entries + #if the chosen partner is not a company and has a parent company, use the parent for the journal entries #because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait' part = inv.partner_id if part.parent_id and not part.is_company: @@ -419,7 +419,7 @@ class account_invoice(osv.osv): try: compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1] except ValueError: - compose_form_id = False + compose_form_id = False ctx = dict(context) ctx.update({ 'default_model': 'account.invoice', @@ -540,11 +540,11 @@ class account_invoice(osv.osv): return result def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice): - res = {} + res = {} if not date_invoice: date_invoice = time.strftime('%Y-%m-%d') if not payment_term_id: - return {'value':{'date_due': date_invoice}} #To make sure the invoice has a due date when no payment term + return {'value':{'date_due': date_invoice}} #To make sure the invoice has a due date when no payment term pterm_list = self.pool.get('account.payment.term').compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice) if pterm_list: pterm_list = [line[0] for line in pterm_list] From 81037740e1166a27a112a6ee878e423ac51eb8dd Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Fri, 15 Feb 2013 18:10:53 +0100 Subject: [PATCH 2/2] [IMP] issue #585361: give a more explicit error message when a user tries to delete an invoice that has been validated (i.e. assigned a sequence number) also, replace the old fashioned exceptions with the new implementation (one rock, two birds) bzr revid: abo@openerp.com-20130215171053-grkz9tkfsy2nkh3y --- addons/account/account_invoice.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 933670a1fd0..6a2a3deccf7 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -451,11 +451,15 @@ class account_invoice(osv.osv): context = {} invoices = self.read(cr, uid, ids, ['state','internal_number'], context=context) unlink_ids = [] + for t in invoices: - if t['state'] in ('draft', 'cancel') and t['internal_number']== False: - unlink_ids.append(t['id']) + if t['state'] not in ('draft', 'cancel'): + raise openerp.exceptions.Warning(_('You cannot delete an invoice which is not cancelled. You should refund it instead.')) + elif t['internal_number'] == False: + raise openerp.exceptions.Warning(_('You cannot delete an invoice after it has been validated (and received a number). You can set it back to "Draft" state and modify its content, then re-confirm it.')) else: - raise osv.except_osv(_('Invalid Action!'), _('You can not delete an invoice which is not cancelled. You should refund it instead.')) + unlink_ids.append(t['id']) + osv.osv.unlink(self, cr, uid, unlink_ids, context=context) return True