[MOV] payment_acquirer: moved paypal_fee_* fields to fees_*, standard fields for an acquirer.
bzr revid: tde@openerp.com-20131202155941-b8nbujgwf57fol2v
This commit is contained in:
parent
3a96d971fa
commit
7896d2e745
|
@ -56,6 +56,12 @@ class PaymentAcquirer(osv.Model):
|
|||
string='Environment'),
|
||||
'portal_published': fields.boolean('Visible in Portal',
|
||||
help="Make this payment acquirer available (Customer invoices, etc.)"),
|
||||
# Fees
|
||||
'fees_active': fields.boolean('Compute fees'),
|
||||
'fees_dom_fixed': fields.float('Fixed domestic fees'),
|
||||
'fees_dom_var': fields.float('Variable domestic fees (in percents)'),
|
||||
'fees_int_fixed': fields.float('Fixed international fees'),
|
||||
'fees_int_var': fields.float('Variable international fees (in percents)'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
|
|
@ -17,11 +17,20 @@
|
|||
<group>
|
||||
<field name="name"/>
|
||||
<field name="company_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="portal_published"/>
|
||||
<field name="env"/>
|
||||
</group>
|
||||
<group>
|
||||
<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>
|
||||
</group>
|
||||
<group name="acquirer_display">
|
||||
<field name="message"/>
|
||||
|
|
|
@ -27,12 +27,6 @@ class AcquirerPaypal(osv.Model):
|
|||
'paypal_username': fields.char('Username', required_if_provider='paypal'),
|
||||
'paypal_tx_url': fields.char('Transaction URL', required_if_provider='paypal'),
|
||||
'paypal_use_ipn': fields.boolean('Use IPN'),
|
||||
# Fees
|
||||
'paypal_fee_active': fields.boolean('Compute fees'),
|
||||
'paypal_fee_dom_fixed': fields.float('Fixed domestic fees'),
|
||||
'paypal_fee_dom_var': fields.float('Variable domestic fees (in percents)'),
|
||||
'paypal_fee_int_fixed': fields.float('Fixed international fees'),
|
||||
'paypal_fee_int_var': fields.float('Variable international fees (in percents)'),
|
||||
# Server 2 server
|
||||
'paypal_api_enabled': fields.boolean('Use Rest API'),
|
||||
'paypal_api_username': fields.char('Rest API Username'),
|
||||
|
@ -44,11 +38,11 @@ class AcquirerPaypal(osv.Model):
|
|||
_defaults = {
|
||||
'paypal_tx_url': 'https://www.sandbox.paypal.com/cgi-bin/webscr',
|
||||
'paypal_use_ipn': True,
|
||||
'paypal_fee_active': False,
|
||||
'paypal_fee_dom_fixed': 0.35,
|
||||
'paypal_fee_dom_var': 3.4,
|
||||
'paypal_fee_int_fixed': 0.35,
|
||||
'paypal_fee_int_var': 3.9,
|
||||
'fees_active': False,
|
||||
'fees_dom_fixed': 0.35,
|
||||
'fees_dom_var': 3.4,
|
||||
'fees_int_fixed': 0.35,
|
||||
'fees_int_var': 3.9,
|
||||
'paypal_api_enabled': False,
|
||||
}
|
||||
|
||||
|
@ -64,9 +58,9 @@ class AcquirerPaypal(osv.Model):
|
|||
acquirer = self.browse(cr, uid, id, context=context)
|
||||
country = self.pool['res.country'].browse(cr, uid, country_id, context=context)
|
||||
if country and acquirer.company_id.country_id.id == country.id:
|
||||
fees = amount * (1 + acquirer.paypal_fee_dom_var / 100.0) + acquirer.paypal_fee_dom_fixed - amount
|
||||
fees = amount * (1 + acquirer.fees_dom_var / 100.0) + acquirer.fees_dom_fixed - amount
|
||||
else:
|
||||
fees = amount * (1 + acquirer.paypal_fee_int_var / 100.0) + acquirer.paypal_fee_int_fixed - amount
|
||||
fees = amount * (1 + acquirer.fees_int_var / 100.0) + acquirer.fees_int_fixed - amount
|
||||
return fees
|
||||
|
||||
def paypal_form_generate_values(self, cr, uid, id, reference, amount, currency, partner_id=False, partner_values=None, tx_custom_values=None, context=None):
|
||||
|
@ -96,7 +90,7 @@ class AcquirerPaypal(osv.Model):
|
|||
'notify_url': '%s' % urlparse.urljoin(base_url, PaypalController._notify_url),
|
||||
'cancel_return': '%s' % urlparse.urljoin(base_url, PaypalController._cancel_url),
|
||||
}
|
||||
if acquirer.paypal_fee_active:
|
||||
if acquirer.fees_active:
|
||||
tx_values['handling'] = '%.2f' % tx_custom_values.pop('fees', 0.0)
|
||||
if tx_custom_values and tx_custom_values.get('return_url'):
|
||||
tx_values['custom'] = json.dumps({'return_url': '%s' % tx_custom_values.pop('return_url')})
|
||||
|
|
|
@ -145,7 +145,7 @@ class PaypalForm(PaypalCommon):
|
|||
def test_11_paypal_form_with_fees(self):
|
||||
cr, uid, context = self.cr, self.uid, {}
|
||||
self.payment_acquirer.write(cr, uid, self.paypal_id, {
|
||||
'paypal_fee_active': True,
|
||||
'fees_active': True,
|
||||
}, context)
|
||||
|
||||
# be sure not to do stupid things
|
||||
|
@ -168,7 +168,7 @@ class PaypalForm(PaypalCommon):
|
|||
if form_input.get('name') in ['handling']:
|
||||
handling_found = True
|
||||
self.assertEqual(form_input.get('value'), '0.84', 'paypal: wrong computed fees')
|
||||
self.assertTrue(handling_found, 'paypal: paypal_fee_active did not add handling input in rendered form')
|
||||
self.assertTrue(handling_found, 'paypal: fees_active did not add handling input in rendered form')
|
||||
|
||||
@mute_logger('openerp.addons.payment_acquirer_paypal.models.paypal', 'ValidationError')
|
||||
def test_20_paypal_form_management(self):
|
||||
|
|
|
@ -19,17 +19,6 @@
|
|||
<field name="paypal_api_password"
|
||||
attrs="{'invisible': [('paypal_api_enabled', '=', False)]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="paypal_fee_active"/>
|
||||
<field name="paypal_fee_dom_fixed"
|
||||
attrs="{'invisible': [('paypal_fee_active', '=', False)]}"/>
|
||||
<field name="paypal_fee_dom_var"
|
||||
attrs="{'invisible': [('paypal_fee_active', '=', False)]}"/>
|
||||
<field name="paypal_fee_int_fixed"
|
||||
attrs="{'invisible': [('paypal_fee_active', '=', False)]}"/>
|
||||
<field name="paypal_fee_int_var"
|
||||
attrs="{'invisible': [('paypal_fee_active', '=', False)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue