From 52125e3cfa74cf984718968a90642f948804b271 Mon Sep 17 00:00:00 2001 From: OpenERP instance user Date: Fri, 9 Dec 2011 14:07:52 +0100 Subject: [PATCH] [ADD] select all candidate invoices by default in the payment order --- account_payment_shortcut/__init__.py | 1 + account_payment_shortcut/__openerp__.py | 43 +++++++++++++++++++++++ account_payment_shortcut/payment_order.py | 31 ++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 account_payment_shortcut/__init__.py create mode 100644 account_payment_shortcut/__openerp__.py create mode 100644 account_payment_shortcut/payment_order.py diff --git a/account_payment_shortcut/__init__.py b/account_payment_shortcut/__init__.py new file mode 100644 index 000000000..da88e0bdd --- /dev/null +++ b/account_payment_shortcut/__init__.py @@ -0,0 +1 @@ +import payment_order diff --git a/account_payment_shortcut/__openerp__.py b/account_payment_shortcut/__openerp__.py new file mode 100644 index 000000000..0d750a309 --- /dev/null +++ b/account_payment_shortcut/__openerp__.py @@ -0,0 +1,43 @@ +############################################################################## +# +# Copyright (C) 2011 Therp BV (). +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Account Payment Invoice Selection Shortcut', + 'version': '6.0.1.64', + 'license': 'GPL-3', + 'author': 'Therp BV', + 'website': 'http://therp.nl', + 'category': 'Banking addons', + 'depends': ['account_payment'], + 'init_xml': [], + 'update_xml': [ + ], + 'demo_xml': [], + 'description': ''' +When composing a payment order, select all candidates by default (in the second step of the "Select invoices to pay" wizard). + ''', + 'active': False, + 'installable': True, +} diff --git a/account_payment_shortcut/payment_order.py b/account_payment_shortcut/payment_order.py new file mode 100644 index 000000000..5953f4910 --- /dev/null +++ b/account_payment_shortcut/payment_order.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from osv import osv, fields + +class payment_order_create(osv.osv_memory): + + _inherit = 'payment.order.create' + + def default_get(self, cr, uid, fields_list, context=None): + """ + Automatically add the candidate move lines to + the payment order, instead of only applying them + to the domain. + + We make use of the fact that the search_entries + method passes an action without a res_id so that a + new instance is created. Inject the line_ids, which have + been placed in the context at object + creation time. + """ + res = super(payment_order_create, self).default_get( + cr, uid, fields_list, context=context) + + if (fields_list and 'entries' in fields_list + and 'entries' not in res + and context and context.get('line_ids', False) + ): + res['entries'] = context['line_ids'] + + return res + +payment_order_create()