From c76201cbddac1ac8b5088c4b8a415423852a6af7 Mon Sep 17 00:00:00 2001 From: rmu-odoo Date: Thu, 21 Jan 2016 14:58:28 +0530 Subject: [PATCH] [IMP] payment : environment as toggle button Environment field on payment.acquirer model now has a shiny stat button on its form view. It allows to toggle between production and testing mode. All payment acquirers are by default in testing environment now, to avoid issues. --- addons/payment/models/payment_acquirer.py | 9 ++++++++- addons/payment/views/payment_acquirer.xml | 14 +++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index f7899376ed4..ff875331361 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -123,7 +123,7 @@ class PaymentAcquirer(osv.Model): _defaults = { 'company_id': lambda self, cr, uid, obj, ctx=None: self.pool['res.users'].browse(cr, uid, uid).company_id.id, - 'environment': 'prod', + 'environment': 'test', 'website_published': False, 'auto_confirm': 'at_pay_confirm', 'pending_msg': 'Pending, Your online payment has been successfully processed. But your order is not validated yet.', @@ -308,6 +308,13 @@ class PaymentAcquirer(osv.Model): return method(cr, uid, id, data, context=context) return True + def toggle_enviroment_value(self, cr, uid, ids, context=None): + acquirers = self.browse(cr, uid, ids, context=context) + prod_ids = [acquirer.id for acquirer in acquirers if acquirer.environment == 'prod'] + test_ids = [acquirer.id for acquirer in acquirers if acquirer.environment == 'test'] + self.write(cr, uid, prod_ids, {'environment': 'test'}, context=context) + self.write(cr, uid, test_ids, {'environment': 'prod'}, context=context) + class PaymentTransaction(osv.Model): """ Transaction Model. Each specific acquirer can extend the model by adding diff --git a/addons/payment/views/payment_acquirer.xml b/addons/payment/views/payment_acquirer.xml index d1817c42aa8..f680bf92602 100644 --- a/addons/payment/views/payment_acquirer.xml +++ b/addons/payment/views/payment_acquirer.xml @@ -23,8 +23,21 @@ payment.acquirer
+
+ + @@ -37,7 +50,6 @@
-