[IMP] payment: only show fees configuration if fees are implemented
This commit is contained in:
@@ -56,6 +56,16 @@ class PaymentAcquirer(osv.Model):
|
||||
def _get_providers(self, cr, uid, context=None):
|
||||
return [('manual', 'Manual Configuration')]
|
||||
|
||||
def _compute_fees_implemented(self, cr, uid, ids, field_names, arg, context=None):
|
||||
acquirer_model = self.pool['payment.acquirer']
|
||||
res = {}
|
||||
|
||||
for acquirer in acquirer_model.browse(cr, uid, ids, context=context):
|
||||
custom_method_name = '%s_compute_fees' % acquirer.provider
|
||||
res[acquirer.id] = hasattr(acquirer_model, custom_method_name)
|
||||
|
||||
return res
|
||||
|
||||
# indirection to ease inheritance
|
||||
_provider_selection = lambda self, *args, **kwargs: self._get_providers(*args, **kwargs)
|
||||
|
||||
@@ -87,6 +97,7 @@ class PaymentAcquirer(osv.Model):
|
||||
'cancel_msg': fields.html('Cancel Message', translate=True, help='Message displayed, if order is cancel during the payment process.'),
|
||||
'error_msg': fields.html('Error Message', translate=True, help='Message displayed, if error is occur during the payment process.'),
|
||||
# Fees
|
||||
'fees_implemented': fields.function(_compute_fees_implemented, type="boolean"),
|
||||
'fees_active': fields.boolean('Add Extra Fees'),
|
||||
'fees_dom_fixed': fields.float('Fixed domestic fees'),
|
||||
'fees_dom_var': fields.float('Variable domestic fees (in percents)'),
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Payment Acquirer">
|
||||
<field name="environment" invisible='1'/>
|
||||
<field name="fees_implemented" invisible='1'/>
|
||||
<sheet>
|
||||
<field name="module_id" invisible="1"/>
|
||||
<field name="module_state" invisible="1"/>
|
||||
@@ -79,11 +80,6 @@
|
||||
<group name="acquirer_config">
|
||||
<field name="auto_confirm" widget="radio"/>
|
||||
<field name="journal_id" attrs="{'required': [('auto_confirm', '=', 'generate_and_pay_invoice')]}"/>
|
||||
<field name="fees_active"/>
|
||||
<field name="fees_dom_fixed" attrs="{'invisible': [('fees_active', '=', False)]}"/>
|
||||
<field name="fees_dom_var" attrs="{'invisible': [('fees_active', '=', False)]}"/>
|
||||
<field name="fees_int_fixed" attrs="{'invisible': [('fees_active', '=', False)]}"/>
|
||||
<field name="fees_int_var" attrs="{'invisible': [('fees_active', '=', False)]}"/>
|
||||
<label for="view_template_id"/>
|
||||
<div>
|
||||
<field name="view_template_id" nolabel="1"/>
|
||||
@@ -106,6 +102,13 @@
|
||||
</div>
|
||||
<field name="registration_view_template_id"/>
|
||||
</group>
|
||||
<group name="fees_config" attrs="{'invisible': [('fees_implemented', '=', False)]}">
|
||||
<field name="fees_active"/>
|
||||
<field name="fees_dom_fixed" attrs="{'invisible': [('fees_active', '=', False)]}"/>
|
||||
<field name="fees_dom_var" attrs="{'invisible': [('fees_active', '=', False)]}"/>
|
||||
<field name="fees_int_fixed" attrs="{'invisible': [('fees_active', '=', False)]}"/>
|
||||
<field name="fees_int_var" attrs="{'invisible': [('fees_active', '=', False)]}"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
|
||||
Reference in New Issue
Block a user