From 90fcce51fa4db6368cf71fd4cf181e2bc46ab71a Mon Sep 17 00:00:00 2001 From: "Dmitrijs Ledkovs (credativ)" Date: Thu, 16 Feb 2012 12:05:41 +0000 Subject: [PATCH] osv_memory wizards --- account_banking/account_banking.py | 47 ++++++++++++++++++++++++ account_banking/account_banking_view.xml | 17 +++++++++ 2 files changed, 64 insertions(+) diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index 01ddc3650..53a517d6f 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -649,6 +649,12 @@ class payment_type(osv.osv): # required=False, # help='Use this to limit this type to a specific country' # ), + 'ir_model_id': fields.many2one( + 'ir.model', 'Payment wizard', + help=('Select the Payment Wizard for payments of this type. ' + 'Leave empty for manual processing'), + domain=[('osv_memory', '=', True)], + ), } #_defaults = { # 'country_id': lambda *a: False, @@ -1013,6 +1019,47 @@ class payment_order(osv.osv): return 'account_banking', 'wizard_account_banking_payment_manual' return super(payment_order, self).get_wizard(type) + def launch_wizard(self, cr, uid, ids, context=None): + """ + Search for a wizard to launch according to the type. + If type is manual. just confirm the order. + Previously (pre-v6) in account_payment/wizard/wizard_pay.py + """ + if context == None: + context={} + result = {} + orders = self.browse(cr, uid, ids, context) + order = orders[0] + # check if a wizard is defined for the first order + if order.mode.type and order.mode.type.ir_model_id: + context['active_ids'] = ids + wizard_model = order.mode.type.ir_model_id.model + wizard_obj = self.pool.get(wizard_model) + wizard_id = wizard_obj.create(cr, uid, {}, context) + result = { + 'name': wizard_obj._description or 'Payment Order Export', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': wizard_model, + 'domain': [], + 'context': context, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'res_id': wizard_id, + 'nodestroy': True, + } + else: + # should all be manual orders without type or wizard model + for order in orders[1:]: + if order.mode.type and order.mode.type.ir_model_id: + raise osv.except_osv( + _('Error'), + _('You can only combine payment orders of the same type') + ) + # process manual payments + self.action_sent(cr, uid, ids, context) + return result + payment_order() class res_partner_bank(osv.osv): diff --git a/account_banking/account_banking_view.xml b/account_banking/account_banking_view.xml index ce1728025..afa4e3b9d 100644 --- a/account_banking/account_banking_view.xml +++ b/account_banking/account_banking_view.xml @@ -279,6 +279,23 @@ string="Select Invoices to Pay" /> + +