[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.
This commit is contained in:
committed by
Thibault Delavallée
parent
6d502823ff
commit
c76201cbdd
@@ -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': '<i>Pending,</i> 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
|
||||
|
||||
@@ -23,8 +23,21 @@
|
||||
<field name="model">payment.acquirer</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Payment Acquirer">
|
||||
<field name="environment" invisible='1'/>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button attrs="{'invisible': [('environment', '=', 'test')]}" class="oe_stat_button" name="toggle_enviroment_value" type="object" icon="fa-play">
|
||||
<div class="o_stat_info o_form_field">
|
||||
<span class="text-success">Production</span>
|
||||
<span class="o_stat_text">Environment</span>
|
||||
</div>
|
||||
</button>
|
||||
<button attrs="{'invisible': [('environment', '=', 'prod')]}" class="oe_stat_button" name="toggle_enviroment_value" type="object" icon="fa-stop">
|
||||
<div class="o_stat_info o_form_field">
|
||||
<span class="text-danger">Test</span>
|
||||
<span class="o_stat_text">Environment</span>
|
||||
</div>
|
||||
</button>
|
||||
<button class="oe_stat_button" name="%(payment_transaction_action_child)d"
|
||||
type="action" icon="fa-money" string="Payments">
|
||||
</button>
|
||||
@@ -37,7 +50,6 @@
|
||||
</div>
|
||||
<group name="acquirer_base" col="2">
|
||||
<group name="acquirer_left">
|
||||
<field name="environment" groups="base.group_no_one"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options='{"no_open":True}'/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user