From 639bcf04d72a6482ea20697577adf2a3e10882e7 Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Tue, 15 Jan 2013 17:40:13 +0100 Subject: [PATCH] [FIX] correction regarding Guewen Baconnier @ Camptocamp comments --- .../__init__.py | 7 +--- .../__openerp__.py | 8 ++--- .../account_invoice.py | 36 +++++++++---------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/account_cancel_invoice_check_payment_order/__init__.py b/account_cancel_invoice_check_payment_order/__init__.py index 2aa5549b3..df03e1a09 100644 --- a/account_cancel_invoice_check_payment_order/__init__.py +++ b/account_cancel_invoice_check_payment_order/__init__.py @@ -1,11 +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 @@ -21,7 +17,6 @@ # along with this program. If not, see . # ############################################################################## - import account_invoice # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_cancel_invoice_check_payment_order/__openerp__.py b/account_cancel_invoice_check_payment_order/__openerp__.py index f39dd45d3..e195c7bcf 100644 --- a/account_cancel_invoice_check_payment_order/__openerp__.py +++ b/account_cancel_invoice_check_payment_order/__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 @@ -20,12 +17,11 @@ # along with this program. If not, see . # ############################################################################## - { "name" : "Cancel invoice, check on payment order", "version" : "1.0", "depends" : ["base", "account","account_payment","account_cancel"], - "author" : "CamptoCamp", + "author" : "Camptocamp", "description": """Constraint to not be able to cancel on invoice if already import in payment order """, 'website': 'http://www.camptocamp.com', diff --git a/account_cancel_invoice_check_payment_order/account_invoice.py b/account_cancel_invoice_check_payment_order/account_invoice.py index b93bb3a03..520900228 100644 --- a/account_cancel_invoice_check_payment_order/account_invoice.py +++ b/account_cancel_invoice_check_payment_order/account_invoice.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 @@ -21,30 +18,33 @@ # ############################################################################## -from tools.translate import _ -from osv import osv -from openerp.osv.orm import TransientModel, fields +from openerp.tools.translate import _ +from openerp.osv import osv, orm +from openerp.osv.orm import TransientModel -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 invoice in invoices: if invoice['move_id']: - ## This invoice have a move line, we search move_line converned by this move - cr.execute("""select (select reference from payment_order where id = order_id) as payment_name, - (select date_done from payment_order where id = order_id) as payment_date, - name from payment_line - where move_line_id in (select id from account_move_line where move_id = %s)""", + ## This invoice have a move line, we search move_line concerned by this move + cr.execute("""SELECT po.reference as payment_name, + po.date_done as payment_date, + pl.name + FROM payment_line as pl + INNER JOIN payment_order AS po + ON pl.id = order_id + WHERE move_line_id IN (SELECT id FROM account_move_line WHERE move_id = %s)""", (invoice['move_id'][0],)) payment_orders = cr.dictfetchall() if payment_orders: - raise osv.except_osv(_('Error !'), _('''Invoice already import in payment \ - order (%s) at %s on line %s''' % + raise osv.except_osv(_('Error !'), + _("Invoice already import in payment" + "order (%s) at %s on line %s" % (payment_orders[0]['payment_name'], payment_orders[0]['payment_date'], payment_orders[0]['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