From 333e83fc5ba22bcd16cfd3b4f492710c2c4a8d5e Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Mon, 18 Mar 2013 13:27:48 +0100 Subject: [PATCH] [REF] account_payment: removal of amount_to_pay field on account.move.line and account.invoice, replaced by amount_residual bzr revid: qdp-launchpad@openerp.com-20130318122748-ac9k5bhka1foadvr --- addons/account_payment/__openerp__.py | 1 - addons/account_payment/account_invoice.py | 10 +--- .../account_payment/account_invoice_view.xml | 15 ----- addons/account_payment/account_move_line.py | 60 +------------------ addons/account_payment/account_payment.py | 2 +- .../account_payment/account_payment_view.xml | 27 +-------- .../wizard/account_payment_order.py | 4 +- 7 files changed, 7 insertions(+), 112 deletions(-) delete mode 100644 addons/account_payment/account_invoice_view.xml diff --git a/addons/account_payment/__openerp__.py b/addons/account_payment/__openerp__.py index 66d0201b2fe..4c3c8f045e3 100644 --- a/addons/account_payment/__openerp__.py +++ b/addons/account_payment/__openerp__.py @@ -53,7 +53,6 @@ have a new option to import payment orders as bank statement lines. 'account_payment_view.xml', 'account_payment_workflow.xml', 'account_payment_sequence.xml', - 'account_invoice_view.xml', 'account_payment_report.xml', ], 'demo': ['account_payment_demo.xml'], diff --git a/addons/account_payment/account_invoice.py b/addons/account_payment/account_invoice.py index 916aa07afa0..bcce77a54ce 100644 --- a/addons/account_payment/account_invoice.py +++ b/addons/account_payment/account_invoice.py @@ -19,9 +19,8 @@ # ############################################################################## -from datetime import datetime from openerp.tools.translate import _ -from openerp.osv import fields, osv +from openerp.osv import osv class Invoice(osv.osv): _inherit = 'account.invoice' @@ -43,13 +42,6 @@ class Invoice(osv.osv): raise osv.except_osv(_('Error!'), _("You cannot cancel an invoice which has already been imported in a payment order. Remove it from the following payment order : %s."%(payment_order_name))) return super(Invoice, self).action_cancel(cr, uid, ids, context=context) - - _columns = { - 'amount_to_pay': fields.related('residual', - type='float', string='Amount to be paid', - help='The amount which should be paid at the current date. '), - } - Invoice() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/account_invoice_view.xml b/addons/account_payment/account_invoice_view.xml deleted file mode 100644 index ebb6bcbf965..00000000000 --- a/addons/account_payment/account_invoice_view.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - account.invoice.supplier.form.inherit - account.invoice - - - - - - - - - diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index 35c30c686e8..c601d9e8da3 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -19,65 +19,12 @@ # ############################################################################## -from operator import itemgetter -from openerp.osv import fields, osv +from openerp.osv import osv from openerp.tools.translate import _ class account_move_line(osv.osv): _inherit = "account.move.line" - def amount_to_pay(self, cr, uid, ids, name, arg=None, context=None): - """ Return the amount still to pay regarding all the payemnt orders - (excepting cancelled orders)""" - if not ids: - return {} - cr.execute("""SELECT ml.id, - CASE WHEN ml.amount_currency < 0 - THEN - ml.amount_currency - ELSE ml.credit - END - - (SELECT coalesce(sum(amount_currency),0) - FROM payment_line pl - INNER JOIN payment_order po - ON (pl.order_id = po.id) - WHERE move_line_id = ml.id - AND po.state != 'cancel') AS amount - FROM account_move_line ml - WHERE id IN %s""", (tuple(ids),)) - r = dict(cr.fetchall()) - return r - - def _to_pay_search(self, cr, uid, obj, name, args, context=None): - if not args: - return [] - line_obj = self.pool.get('account.move.line') - query = line_obj._query_get(cr, uid, context={}) - where = ' and '.join(map(lambda x: '''(SELECT - CASE WHEN l.amount_currency < 0 - THEN - l.amount_currency - ELSE l.credit - END - coalesce(sum(pl.amount_currency), 0) - FROM payment_line pl - INNER JOIN payment_order po ON (pl.order_id = po.id) - WHERE move_line_id = l.id - AND po.state != 'cancel' - ) %(operator)s %%s ''' % {'operator': x[1]}, args)) - sql_args = tuple(map(itemgetter(2), args)) - - cr.execute(('''SELECT id - FROM account_move_line l - WHERE account_id IN (select id - FROM account_account - WHERE type=%s AND active) - AND reconcile_id IS null - AND credit > 0 - AND ''' + where + ' and ' + query), ('payable',)+sql_args ) - - res = cr.fetchall() - if not res: - return [('id', '=', '0')] - return [('id', 'in', map(lambda x:x[0], res))] - def line2bank(self, cr, uid, ids, payment_type=None, context=None): """ Try to return for each Ledger Posting line a corresponding bank @@ -110,11 +57,6 @@ class account_move_line(osv.osv): raise osv.except_osv(_('Error!'), _('There is no partner defined on the entry line.')) return line2bank - _columns = { - 'amount_to_pay': fields.function(amount_to_pay, - type='float', string='Amount to pay', fnct_search=_to_pay_search), - } - account_move_line() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index bf0377111a8..2b0fe1271d2 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -352,7 +352,7 @@ class payment_line(osv.osv): if move_line_id: line = move_line_obj.browse(cr, uid, move_line_id, context=context) - data['amount_currency'] = line.amount_to_pay + data['amount_currency'] = line.amount_residual_currency res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency, company_currency, context) diff --git a/addons/account_payment/account_payment_view.xml b/addons/account_payment/account_payment_view.xml index c2f27a576a2..aa52d1d443e 100644 --- a/addons/account_payment/account_payment_view.xml +++ b/addons/account_payment/account_payment_view.xml @@ -2,29 +2,6 @@ - - - account.move.line.form.inherit - account.move.line - - - - - - - - - - @@ -116,7 +93,7 @@ - +