summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
Diffstat (limited to 'addons')
-rw-r--r--addons/payment/controllers/portal.py4
-rw-r--r--addons/payment/models/payment_acquirer.py61
-rw-r--r--addons/payment/views/payment_portal_templates.xml2
-rw-r--r--addons/payment/views/payment_views.xml67
-rw-r--r--addons/payment/wizards/payment_acquirer_onboarding_wizard.py9
-rw-r--r--addons/payment_adyen/data/payment_acquirer_data.xml4
-rw-r--r--addons/payment_adyen/models/payment.py4
-rw-r--r--addons/payment_adyen/tests/test_adyen.py11
-rw-r--r--addons/payment_adyen/views/payment_views.xml6
-rw-r--r--addons/payment_alipay/controllers/main.py2
-rw-r--r--addons/payment_alipay/data/payment_acquirer_data.xml4
-rw-r--r--addons/payment_alipay/models/payment.py4
-rw-r--r--addons/payment_alipay/tests/test_alipay.py14
-rw-r--r--addons/payment_authorize/data/payment_acquirer_data.xml4
-rw-r--r--addons/payment_authorize/models/authorize_request.py6
-rw-r--r--addons/payment_authorize/models/payment.py3
-rw-r--r--addons/payment_authorize/static/src/js/payment_form.js2
-rw-r--r--addons/payment_authorize/tests/test_authorize.py12
-rw-r--r--addons/payment_authorize/views/payment_authorize_templates.xml2
-rw-r--r--addons/payment_authorize/views/payment_views.xml6
-rw-r--r--addons/payment_buckaroo/data/payment_acquirer_data.xml3
-rw-r--r--addons/payment_buckaroo/models/payment.py6
-rw-r--r--addons/payment_buckaroo/tests/test_buckaroo.py10
-rw-r--r--addons/payment_buckaroo/views/payment_views.xml4
-rw-r--r--addons/payment_ingenico/data/payment_acquirer_data.xml8
-rw-r--r--addons/payment_ingenico/models/payment.py12
-rw-r--r--addons/payment_ingenico/tests/test_ogone.py16
-rw-r--r--addons/payment_ingenico/views/payment_views.xml10
-rw-r--r--addons/payment_paypal/controllers/main.py2
-rw-r--r--addons/payment_paypal/data/payment_acquirer_data.xml1
-rw-r--r--addons/payment_paypal/models/payment.py6
-rw-r--r--addons/payment_paypal/tests/test_paypal.py10
-rw-r--r--addons/payment_paypal/views/payment_views.xml8
-rw-r--r--addons/payment_payulatam/data/payment_acquirer_data.xml4
-rw-r--r--addons/payment_payulatam/models/payment.py3
-rw-r--r--addons/payment_payulatam/tests/test_payulatam.py10
-rw-r--r--addons/payment_payumoney/data/payment_acquirer_data.xml3
-rw-r--r--addons/payment_payumoney/models/payment.py3
-rw-r--r--addons/payment_payumoney/views/payment_views.xml4
-rw-r--r--addons/payment_sips/data/payment_acquirer_data.xml3
-rw-r--r--addons/payment_sips/models/payment.py6
-rw-r--r--addons/payment_sips/views/payment_views.xml10
-rw-r--r--addons/payment_stripe/data/payment_acquirer_data.xml3
-rw-r--r--addons/payment_stripe/tests/test_stripe.py11
-rw-r--r--addons/payment_stripe/views/payment_views.xml4
-rw-r--r--addons/payment_transfer/data/payment_acquirer_data.xml3
-rw-r--r--addons/sale/controllers/portal.py2
-rw-r--r--addons/website_sale/controllers/main.py2
48 files changed, 190 insertions, 204 deletions
diff --git a/addons/payment/controllers/portal.py b/addons/payment/controllers/portal.py
index 4db7e0153ea..8817134b8b6 100644
--- a/addons/payment/controllers/portal.py
+++ b/addons/payment/controllers/portal.py
@@ -111,7 +111,7 @@ class WebsitePayment(http.Controller):
@http.route(['/my/payment_method'], type='http', auth="user", website=True)
def payment_method(self, **kwargs):
acquirers = list(request.env['payment.acquirer'].search([
- ('website_published', '=', True), ('registration_view_template_id', '!=', False),
+ ('state', '=', 'enabled'), ('registration_view_template_id', '!=', False),
('payment_flow', '=', 's2s'), ('company_id', '=', request.env.company.id)
]))
partner = request.env.user.partner_id
@@ -178,7 +178,7 @@ class WebsitePayment(http.Controller):
if acquirer_id:
acquirers = env['payment.acquirer'].browse(int(acquirer_id))
if not acquirers:
- acquirers = env['payment.acquirer'].search([('website_published', '=', True), ('company_id', '=', user.company_id.id)])
+ acquirers = env['payment.acquirer'].search([('state', '=', 'enabled'), ('company_id', '=', user.company_id.id)])
# Check partner
partner_id = user.partner_id.id if not user._is_public() else False
diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py
index b7153bf5f0e..bbe6fa81c69 100644
--- a/addons/payment/models/payment_acquirer.py
+++ b/addons/payment/models/payment_acquirer.py
@@ -59,12 +59,13 @@ class PaymentAcquirer(models.Model):
"""
_name = 'payment.acquirer'
_description = 'Payment Acquirer'
- _order = 'website_published desc, sequence, name'
+ _order = 'state desc, sequence, name'
def _get_default_view_template_id(self):
return self.env.ref('payment.default_acquirer_button', raise_if_not_found=False)
name = fields.Char('Name', required=True, translate=True)
+ color = fields.Integer('Color', compute='_compute_color', store=True)
description = fields.Html('Description')
sequence = fields.Integer('Sequence', default=10, help="Determine the display order")
provider = fields.Selection(
@@ -91,14 +92,14 @@ class PaymentAcquirer(models.Model):
registration_view_template_id = fields.Many2one(
'ir.ui.view', 'S2S Form Template', domain=[('type', '=', 'qweb')],
help="Template for method registration")
- environment = fields.Selection([
- ('test', 'Test'),
- ('prod', 'Production')], string='Environment',
- default='test', required=True)
- website_published = fields.Boolean(
- 'Visible in Portal / Website', copy=False,
- help="Make this payment acquirer available (Customer invoices, etc.)")
- # Formerly associated to `authorize` option from auto_confirm
+ state = fields.Selection([
+ ('disabled', 'Disabled'),
+ ('enabled', 'Enabled'),
+ ('test', 'Test Mode')], required=True, default='disabled',
+ help="""In test mode, a fake payment is processed through a test
+ payment interface. This mode is advised when setting up the
+ acquirer. Watch out, test and production modes require
+ different credentials.""")
capture_manually = fields.Boolean(string="Capture Amount Manually",
help="Capture the amount from Odoo, when the delivery is completed.")
journal_id = fields.Many2one(
@@ -154,7 +155,7 @@ class PaymentAcquirer(models.Model):
# TDE FIXME: remove that brol
module_id = fields.Many2one('ir.module.module', string='Corresponding Module')
- module_state = fields.Selection(selection=ir_module.STATES, string='Installation State', related='module_id.state', readonly=False)
+ module_state = fields.Selection(selection=ir_module.STATES, string='Installation State', related='module_id.state', store=True)
image_128 = fields.Image("Image", max_width=128, max_height=128)
@@ -174,12 +175,18 @@ class PaymentAcquirer(models.Model):
elif electronic in self.inbound_payment_method_ids:
self.inbound_payment_method_ids = [(2, electronic.id)]
+ @api.onchange('state')
+ def onchange_state(self):
+ """Disable dashboard display for test acquirer journal."""
+ self.journal_id.update({'show_on_dashboard': self.state == 'enabled'})
+
def _search_is_tokenized(self, operator, value):
tokenized = self._get_feature_support()['tokenize']
if (operator, value) in [('=', True), ('!=', False)]:
return [('provider', 'in', tokenized)]
return [('provider', 'not in', tokenized)]
+ @api.depends('provider')
def _compute_feature_support(self):
feature_support = self._get_feature_support()
for acquirer in self:
@@ -187,15 +194,28 @@ class PaymentAcquirer(models.Model):
acquirer.authorize_implemented = acquirer.provider in feature_support['authorize']
acquirer.token_implemented = acquirer.provider in feature_support['tokenize']
+ @api.depends('state', 'module_state')
+ def _compute_color(self):
+ for acquirer in self:
+ if acquirer.module_id and not acquirer.module_state == 'installed':
+ acquirer.color = 4 # blue
+ elif acquirer.state == 'disabled':
+ acquirer.color = 3 # yellow
+ elif acquirer.state == 'test':
+ acquirer.color = 2 # orange
+ elif acquirer.state == 'enabled':
+ acquirer.color = 7 # green
+
def _check_required_if_provider(self):
""" If the field has 'required_if_provider="<provider>"' attribute, then it
required if record.provider is <provider>. """
field_names = []
+ enabled_acquirers = self.filtered(lambda acq: acq.state in ['enabled', 'test'])
for k, f in self._fields.items():
provider = getattr(f, 'required_if_provider', None)
if provider and any(
acquirer.provider == provider and not acquirer[k]
- for acquirer in self
+ for acquirer in enabled_acquirers
):
ir_field = self.env['ir.model.fields']._get(self._name, k)
field_names.append(ir_field.field_description)
@@ -234,7 +254,7 @@ class PaymentAcquirer(models.Model):
'default_debit_account_id': account.id,
'default_credit_account_id': account.id,
# Show the journal on dashboard if the acquirer is published on the website.
- 'show_on_dashboard': self.website_published,
+ 'show_on_dashboard': self.state == 'enabled',
# Don't show payment methods in the backend.
'inbound_payment_method_ids': inbound_payment_method_ids,
'outbound_payment_method_ids': [],
@@ -277,16 +297,6 @@ class PaymentAcquirer(models.Model):
self._check_required_if_provider()
return result
- def toggle_website_published(self):
- ''' When clicking on the website publish toggle button, the website_published is reversed and
- the acquirer journal is set or not in favorite on the dashboard.
- '''
- self.ensure_one()
- self.website_published = not self.website_published
- if self.journal_id:
- self.journal_id.show_on_dashboard = self.website_published
- return True
-
def get_acquirer_extra_fees(self, amount, currency_id, country_id):
extra_fees = {
'currency_id': currency_id
@@ -318,7 +328,7 @@ class PaymentAcquirer(models.Model):
company = self.env.company
if not partner:
partner = self.env.user.partner_id
- active_acquirers = self.sudo().search([('website_published', '=', True), ('company_id', '=', company.id)])
+ active_acquirers = self.sudo().search([('state', '=', 'enabled'), ('company_id', '=', company.id)])
acquirers = active_acquirers.filtered(lambda acq: (acq.payment_flow == 'form' and acq.view_template_id) or
(acq.payment_flow == 's2s' and acq.registration_view_template_id))
return {
@@ -481,11 +491,6 @@ class PaymentAcquirer(models.Model):
return method(data)
return True
- def toggle_environment_value(self):
- prod = self.filtered(lambda acquirer: acquirer.environment == 'prod')
- prod.write({'environment': 'test'})
- (self-prod).write({'environment': 'prod'})
-
def button_immediate_install(self):
# TDE FIXME: remove that brol
if self.module_id and self.module_state != 'installed':
diff --git a/addons/payment/views/payment_portal_templates.xml b/addons/payment/views/payment_portal_templates.xml
index 20d519599be..d09b7a6d779 100644
--- a/addons/payment/views/payment_portal_templates.xml
+++ b/addons/payment/views/payment_portal_templates.xml
@@ -33,7 +33,7 @@
<!-- TDE FIXME: was customize_show=True -->
<template id="pay_meth_link" inherit_id="portal.portal_layout">
<xpath expr="//div[hasclass('o_portal_my_details')]" position="inside">
- <t t-if="request.env['payment.acquirer'].search([('website_published', '=', True), ('registration_view_template_id', '!=', False), ('payment_flow', '=', 's2s'), ('company_id', '=', request.env.company.id)])">
+ <t t-if="request.env['payment.acquirer'].search([('state', 'in', ['enabled', 'test']), ('registration_view_template_id', '!=', False), ('payment_flow', '=', 's2s'), ('company_id', '=', request.env.company.id)])">
<div class='manage_payment_method mt16'><a href="/my/payment_method">Manage payment methods</a></div>
</t>
</xpath>
diff --git a/addons/payment/views/payment_views.xml b/addons/payment/views/payment_views.xml
index 0d6e2ea8f1c..1968e13790b 100644
--- a/addons/payment/views/payment_views.xml
+++ b/addons/payment/views/payment_views.xml
@@ -14,66 +14,29 @@
<field name="model">payment.acquirer</field>
<field name="arch" type="xml">
<form string="Payment Acquirer">
- <field name="environment" invisible='1'/>
<field name="fees_implemented" invisible='1'/>
<field name="token_implemented" invisible='1'/>
<field name="authorize_implemented" invisible="1"/>
- <field name="website_published" invisible="1"/>
<sheet>
<field name="module_id" invisible="1"/>
<field name="module_state" invisible="1"/>
<field name="inbound_payment_method_ids" invisible="1"/>
- <div class="oe_button_box" name="button_box" attrs="{'invisible': ['&amp;', ('module_id', '!=', False), ('module_state', '!=', 'installed')]}">
- <!-- transfer referenced here due to view inheritance issue in current master (post-saas-16) -->
- <button name="toggle_environment_value"
- attrs="{'invisible': ['|', ('environment', '=', 'test'), ('provider', '=', 'transfer')]}"
- class="oe_stat_button"
- type="object" icon="fa-play">
- <div class="o_stat_info o_field_widget">
- <span class="text-success">Production</span>
- <span class="o_stat_text">Environment</span>
- </div>
- </button>
- <!-- transfer referenced here due to view inheritance issue in current master (post-saas-16) -->
- <button name="toggle_environment_value"
- attrs="{'invisible': ['|', ('environment', '=', 'prod'), ('provider', '=', 'transfer')]}"
- class="oe_stat_button"
- type="object" icon="fa-stop">
- <div class="o_stat_info o_field_widget">
- <span class="o_warning_text">Test</span>
- <span class="o_stat_text">Environment</span>
- </div>
- </button>
- <button name="toggle_website_published"
- attrs="{'invisible': [('website_published', '=', True)]}"
- class="oe_stat_button"
- type="object" icon="fa-globe">
- <div class="o_stat_info o_field_widget">
- <span class="text-danger">Unpublished</span>
- </div>
- </button>
- <button name="toggle_website_published"
- attrs="{'invisible': [('website_published', '=', False)]}"
- class="oe_stat_button"
- type="object" icon="fa-globe">
- <div class="o_stat_info o_field_widget">
- <span class="text-success">Published</span>
- </div>
- </button>
- </div>
<field name="image_128" widget="image" class="oe_avatar"/>
<div class="oe_title">
<h1><field name="name" placeholder="Name"/></h1>
+ <div attrs="{'invisible': ['|', ('module_state', '=', 'installed'), ('module_id', '=', False)]}">
+ <button type="object" class="btn btn-primary" name="button_immediate_install" string="Install"/>
+ </div>
</div>
<div attrs="{'invisible': ['|', ('module_state', '=', 'installed'), ('module_id', '=', False)]}">
- <button type="object" class="btn btn-primary" name="button_immediate_install" string="Install"/>
<div class="o_payment_acquirer_desc">
<field name="description"/>
</div>
</div>
- <group name="acquirer_base" col="2" attrs="{'invisible': ['&amp;', ('module_id', '!=', False), ('module_state', '!=', 'installed')]}">
- <group name="acquirer_left">
+ <group>
+ <group name="payment_state">
<field name="provider" groups="base.group_no_one" attrs="{'invisible': [('module_id', '!=', False), ('module_state', '!=', 'installed')]}"/>
+ <field name="state" widget="radio"/>
<field name="company_id" groups="base.group_multi_company" options='{"no_open":True}'/>
</group>
</group>
@@ -111,7 +74,7 @@
<field name="fees_int_var" attrs="{'invisible': [('fees_active', '=', False)]}"/>
</group>
</page>
- <page string="Messages">
+ <page string="Messages" attrs="{'invisible': [('module_id', '=', True), ('module_state', '!=', 'installed')]}">
<group>
<field name="pre_msg" invisible="1"/>
<field name="post_msg"/>
@@ -137,15 +100,14 @@
<field name="id"/>
<field name="name"/>
<field name="description"/>
- <field name="environment"/>
<field name="provider"/>
<field name="module_id"/>
<field name="module_state"/>
- <field name="website_published"/>
+ <field name="color"/>
<templates>
<t t-name="kanban-box">
<t t-set="installed" t-value="!record.module_id.value || (record.module_id.value &amp;&amp; record.module_state.raw_value === 'installed')"/>
- <div t-attf-class="oe_kanban_global_click #{installed and record.website_published.raw_value ? 'oe_kanban_color_5' : 'oe_kanban_color_white'}">
+ <div t-attf-class="oe_kanban_global_click #{kanban_color(record.color.raw_value)}">
<div class="o_kanban_image">
<img type="open" t-att-src="kanban_image('payment.acquirer', 'image_128', record.id.raw_value)" alt="Acquirer"/>
</div>
@@ -155,11 +117,11 @@
</div>
<div class="o_payment_acquirer_bottom">
<t t-if="installed">
- <field name="environment" widget="label_selection" options="{'classes': {'test': 'warning', 'production': 'success'}}"/>
+ <field name="state" widget="label_selection" options="{'classes': {'enabled': 'success', 'test': 'warning', 'disabled' : 'danger'}}"/>
</t>
<button t-if="!installed and !selection_mode" type="object" class="btn btn-secondary float-right" name="button_immediate_install">Install</button>
- <button t-if="installed and !record.website_published.raw_value and !selection_mode" type="edit" class="btn btn-primary float-right">Activate</button>
- <button t-if="installed and record.website_published.raw_value and !selection_mode" type="edit" class="btn btn-primary float-right">Configure</button>
+ <button t-if="installed and record.state.raw_value == 'disabled' and !selection_mode" type="edit" class="btn btn-primary float-right">Activate</button>
+ <button t-if="installed and record.state.raw_value in ['enabled', 'test'] and !selection_mode" type="edit" class="btn btn-primary float-right">Configure</button>
</div>
</div>
</t>
@@ -176,8 +138,7 @@
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="provider"/>
- <field name="website_published"/>
- <field name="environment"/>
+ <field name="state"/>
<field name="country_ids" widget="many2many_tags" optional="hide"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
@@ -194,7 +155,7 @@
<filter name="acquirer_installed" string="Installed" domain="[('provider', '!=', 'manual')]"/>
<group expand="0" string="Group By">
<filter string="Provider" name="provider" domain="[]" context="{'group_by': 'provider'}"/>
- <filter string="Environment" name="environment" domain="[]" context="{'group_by': 'environment'}"/>
+ <filter string="State" name="state" domain="[]" context="{'group_by': 'state'}"/>
</group>
</search>
</field>
diff --git a/addons/payment/wizards/payment_acquirer_onboarding_wizard.py b/addons/payment/wizards/payment_acquirer_onboarding_wizard.py
index ca44e9dfbc1..1c29cc2a0d6 100644
--- a/addons/payment/wizards/payment_acquirer_onboarding_wizard.py
+++ b/addons/payment/wizards/payment_acquirer_onboarding_wizard.py
@@ -115,15 +115,13 @@ class PaymentWizard(models.TransientModel):
'paypal_email_account': self.paypal_email_account,
'paypal_seller_account': self.paypal_seller_account,
'paypal_pdt_token': self.paypal_pdt_token,
- 'website_published': True,
- 'environment': 'prod',
+ 'state': 'enabled',
})
if self.payment_method == 'stripe':
new_env.ref('payment.payment_acquirer_stripe').write({
'stripe_secret_key': self.stripe_secret_key,
'stripe_publishable_key': self.stripe_publishable_key,
- 'website_published': True,
- 'environment': 'prod',
+ 'state': 'enabled',
})
if self.payment_method == 'manual':
manual_acquirer = self._get_manual_payment_acquirer(new_env)
@@ -134,8 +132,7 @@ class PaymentWizard(models.TransientModel):
))
manual_acquirer.name = self.manual_name
manual_acquirer.post_msg = self.manual_post_msg
- manual_acquirer.website_published = True
- manual_acquirer.environment = 'prod'
+ manual_acquirer.state = 'enabled'
journal = manual_acquirer.journal_id
if journal:
diff --git a/addons/payment_adyen/data/payment_acquirer_data.xml b/addons/payment_adyen/data/payment_acquirer_data.xml
index 18e3bb8afde..ba877ca5058 100644
--- a/addons/payment_adyen/data/payment_acquirer_data.xml
+++ b/addons/payment_adyen/data/payment_acquirer_data.xml
@@ -8,12 +8,8 @@
<field name="provider">adyen</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="adyen_form"/>
- <field name="environment">test</field>
<field name="pre_msg"><![CDATA[
<p>You will be redirected to the Adyen website after clicking on the payment button.</p>]]></field>
- <field name="adyen_merchant_account">dummy</field>
- <field name="adyen_skin_code">dummy</field>
- <field name="adyen_skin_hmac_key">dummy</field>
</record>
</data>
diff --git a/addons/payment_adyen/models/payment.py b/addons/payment_adyen/models/payment.py
index 66001bc69b4..584e28ab4a0 100644
--- a/addons/payment_adyen/models/payment.py
+++ b/addons/payment_adyen/models/payment.py
@@ -191,7 +191,9 @@ class AcquirerAdyen(models.Model):
return values
def adyen_get_form_action_url(self):
- return self._get_adyen_urls(self.environment)['adyen_form_url']
+ self.ensure_one()
+ environment = 'prod' if self.state == 'enabled' else 'test'
+ return self._get_adyen_urls(environment)['adyen_form_url']
class TxAdyen(models.Model):
diff --git a/addons/payment_adyen/tests/test_adyen.py b/addons/payment_adyen/tests/test_adyen.py
index 16462b74667..bb02532a06c 100644
--- a/addons/payment_adyen/tests/test_adyen.py
+++ b/addons/payment_adyen/tests/test_adyen.py
@@ -28,6 +28,13 @@ class AdyenCommon(PaymentAcquirerCommon):
self.dsmastercard = (('521234567890 1234', '737', 'user', 'password'))
self.dsvisa = (('4212345678901237', '737', 'user', 'password'))
self.mistercash = (('6703444444444449', None, 'user', 'password'))
+ self.adyen = self.env.ref('payment.payment_acquirer_adyen')
+ self.adyen.write({
+ 'adyen_merchant_account': 'dummy',
+ 'adyen_skin_code': 'dummy',
+ 'adyen_skin_hmac_key': 'dummy',
+ 'state': 'test',
+ })
@odoo.tests.tagged('post_install', '-at_install', 'external', '-standard')
@@ -35,8 +42,8 @@ class AdyenForm(AdyenCommon):
def test_10_adyen_form_render(self):
# be sure not to do stupid things
- adyen = self.env.ref('payment.payment_acquirer_adyen')
- self.assertEqual(adyen.environment, 'test', 'test without test environment')
+ adyen = self.adyen
+ self.assertEqual(adyen.state, 'test', 'test without test environment')
# ----------------------------------------
# Test: button direct rendering
diff --git a/addons/payment_adyen/views/payment_views.xml b/addons/payment_adyen/views/payment_views.xml
index 8d4beeb69b1..af6fac2582d 100644
--- a/addons/payment_adyen/views/payment_views.xml
+++ b/addons/payment_adyen/views/payment_views.xml
@@ -9,9 +9,9 @@
<field name="arch" type="xml">
<xpath expr='//group[@name="acquirer"]' position='inside'>
<group attrs="{'invisible': [('provider', '!=', 'adyen')]}">
- <field name="adyen_merchant_account"/>
- <field name="adyen_skin_code"/>
- <field name="adyen_skin_hmac_key"/>
+ <field name="adyen_merchant_account" attrs="{'required':[('provider', '=', 'adyen'), ('state', '!=', 'disabled')]}"/>
+ <field name="adyen_skin_code" attrs="{'required':[('provider', '=', 'adyen'), ('state', '!=', 'disabled')]}"/>
+ <field name="adyen_skin_hmac_key" attrs="{'required':[('provider', '=', 'adyen'), ('state', '!=', 'disabled')]}"/>
<a colspan="2" href="https://www.adyen.com/home/payment-services/online-payments" target="_blank">How to configure your Adyen account?</a>
</group>
</xpath>
diff --git a/addons/payment_alipay/controllers/main.py b/addons/payment_alipay/controllers/main.py
index 14fc05efca8..5763313b1a9 100644
--- a/addons/payment_alipay/controllers/main.py
+++ b/addons/payment_alipay/controllers/main.py
@@ -40,7 +40,7 @@ class AlipayController(http.Controller):
'partner': alipay.alipay_merchant_partner_id,
'notify_id': post['notify_id']
}
- response = requests.post(alipay._get_alipay_urls(alipay.environment), val)
+ response = requests.post(alipay.alipay_get_form_action_url(), val)
response.raise_for_status()
_logger.info('Validate alipay Notification %s' % response.text)
# After program is executed, the page must print “success” (without quote). If not, Alipay server would keep re-sending notification, until over 24 hour 22 minutes Generally, there are 8 notifications within 25 hours (Frequency: 2m,10m,15m,1h,2h,6h,15h)
diff --git a/addons/payment_alipay/data/payment_acquirer_data.xml b/addons/payment_alipay/data/payment_acquirer_data.xml
index a608788e5fa..88930847eca 100644
--- a/addons/payment_alipay/data/payment_acquirer_data.xml
+++ b/addons/payment_alipay/data/payment_acquirer_data.xml
@@ -5,14 +5,10 @@
<field name="provider">alipay</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="alipay_form"/>
- <field name="environment">test</field>
<field name="pre_msg" type="html">
<p>
You will be redirected to the Alipay website after clicking on the payment button.
</p>
</field>
- <field name="alipay_merchant_partner_id">dummy</field>
- <field name="alipay_md5_signature_key">dummy</field>
- <field name="alipay_seller_email">dummy</field>
</record>
</odoo>
diff --git a/addons/payment_alipay/models/payment.py b/addons/payment_alipay/models/payment.py
index d1fcf343cb5..e56dcae8f4f 100644
--- a/addons/payment_alipay/models/payment.py
+++ b/addons/payment_alipay/models/payment.py
@@ -110,7 +110,9 @@ class PaymentAcquirer(models.Model):
return values
def alipay_get_form_action_url(self):
- return self._get_alipay_urls(self.environment)
+ self.ensure_one()
+ environment = 'prod' if self.state == 'enabled' else 'test'
+ return self._get_alipay_urls(environment)
class PaymentTransaction(models.Model):
diff --git a/addons/payment_alipay/tests/test_alipay.py b/addons/payment_alipay/tests/test_alipay.py
index 511231dd8f1..51e8e22fbfb 100644
--- a/addons/payment_alipay/tests/test_alipay.py
+++ b/addons/payment_alipay/tests/test_alipay.py
@@ -22,10 +22,16 @@ class AlipayTest(PaymentAcquirerCommon):
('active', '=', True),
('active', '=', False)], limit=1)
self.alipay = self.env.ref('payment.payment_acquirer_alipay')
+ self.alipay.write({
+ 'alipay_merchant_partner_id': 'dummy',
+ 'alipay_md5_signature_key': 'dummy',
+ 'alipay_seller_email': 'dummy',
+ 'state': 'test',
+ })
def test_10_alipay_form_render(self):
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
- self.assertEqual(self.alipay.environment, 'test', 'test without test environment')
+ self.assertEqual(self.alipay.state, 'test', 'test without test environment')
# ----------------------------------------
# Test: button direct rendering
@@ -73,7 +79,7 @@ class AlipayTest(PaymentAcquirerCommon):
self.assertEqual(form_input.get('value'), form_values[form_input.get('name')], 'alipay: wrong value for input %s: received %s instead of %s' % (form_input.get('name'), form_input.get('value'), form_values[form_input.get('name')]))
def test_11_alipay_form_with_fees(self):
- self.assertEqual(self.alipay.environment, 'test', 'test without test environment')
+ self.assertEqual(self.alipay.state, 'test', 'test without test environment')
# update acquirer: compute fees
self.alipay.write({
@@ -106,7 +112,7 @@ class AlipayTest(PaymentAcquirerCommon):
self._test_20_alipay_form_management()
def _test_20_alipay_form_management(self):
- self.assertEqual(self.alipay.environment, 'test', 'test without test environment')
+ self.assertEqual(self.alipay.state, 'test', 'test without test environment')
# typical data posted by alipay after client has successfully paid
alipay_post_data = {
@@ -192,4 +198,4 @@ class AlipayTest(PaymentAcquirerCommon):
'currency_id': self.currency_yuan.id,
'reference': 'test_ref_2',
'partner_country_id': self.country_france.id
- }) \ No newline at end of file
+ })
diff --git a/addons/payment_authorize/data/payment_acquirer_data.xml b/addons/payment_authorize/data/payment_acquirer_data.xml
index eda969f9c75..746cb50742b 100644
--- a/addons/payment_authorize/data/payment_acquirer_data.xml
+++ b/addons/payment_authorize/data/payment_acquirer_data.xml
@@ -9,12 +9,8 @@
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="authorize_form"/>
<field name="registration_view_template_id" ref="authorize_s2s_form"/>
- <field name="environment">test</field>
<field name="pre_msg"><![CDATA[
<p>You will be redirected to the Authorize website after clicking on the payment button.</p>]]></field>
- <field name='authorize_login'>dummy</field>
- <field name="authorize_transaction_key">dummy</field>
- <field name="authorize_signature_key">dummy</field>
</record>
</data>
diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py
index 53f40bfb1af..80b9e4bdbf2 100644
--- a/addons/payment_authorize/models/authorize_request.py
+++ b/addons/payment_authorize/models/authorize_request.py
@@ -30,12 +30,12 @@ class AuthorizeAPI():
:param record acquirer: payment.acquirer account that will be contacted
"""
- if acquirer.environment == 'test':
+ if acquirer.state == 'test':
self.url = 'https://apitest.authorize.net/xml/v1/request.api'
else:
self.url = 'https://api.authorize.net/xml/v1/request.api'
- self.environment = acquirer.environment
+ self.state = acquirer.state
self.name = acquirer.authorize_login
self.transaction_key = acquirer.authorize_transaction_key
@@ -99,7 +99,7 @@ class AuthorizeAPI():
}
}
},
- 'validationMode': 'liveMode' if self.environment == 'prod' else 'testMode'
+ 'validationMode': 'liveMode' if self.state == 'enabled' else 'testMode'
}
}
diff --git a/addons/payment_authorize/models/payment.py b/addons/payment_authorize/models/payment.py
index fcc70e6682d..e7be116700d 100644
--- a/addons/payment_authorize/models/payment.py
+++ b/addons/payment_authorize/models/payment.py
@@ -125,7 +125,8 @@ class PaymentAcquirerAuthorize(models.Model):
def authorize_get_form_action_url(self):
self.ensure_one()
- return self._get_authorize_urls(self.environment)['authorize_form_url']
+ environment = 'prod' if self.state == 'enabled' else 'test'
+ return self._get_authorize_urls(environment)['authorize_form_url']
@api.model
def authorize_s2s_form_process(self, data):
diff --git a/addons/payment_authorize/static/src/js/payment_form.js b/addons/payment_authorize/static/src/js/payment_form.js
index 3947111ac1e..11eda20b21d 100644
--- a/addons/payment_authorize/static/src/js/payment_form.js
+++ b/addons/payment_authorize/static/src/js/payment_form.js
@@ -37,7 +37,7 @@ PaymentForm.include({
console.warn('payment_form: unset partner_id when adding new token; things could go wrong');
}
var AcceptJs = false;
- if (formData.acquirer_environment === 'prod') {
+ if (formData.acquirer_state === 'enabled') {
AcceptJs = 'https://js.authorize.net/v3/AcceptUI.js';
} else {
AcceptJs = 'https://jstest.authorize.net/v3/AcceptUI.js';
diff --git a/addons/payment_authorize/tests/test_authorize.py b/addons/payment_authorize/tests/test_authorize.py
index 8bcb40f00e7..c295f0785bc 100644
--- a/addons/payment_authorize/tests/test_authorize.py
+++ b/addons/payment_authorize/tests/test_authorize.py
@@ -20,6 +20,12 @@ class AuthorizeCommon(PaymentAcquirerCommon):
self.currency_usd = self.env['res.currency'].search([('name', '=', 'USD')], limit=1)[0]
# get the authorize account
self.authorize = self.env.ref('payment.payment_acquirer_authorize')
+ self.authorize.write({
+ 'authorize_login': 'dummy',
+ 'authorize_transaction_key': 'dummy',
+ 'authorize_signature_key': 'dummy',
+ 'state': 'test',
+ })
# Be sure to be in 'capture' mode
# self.authorize.auto_confirm = 'confirm_so'
@@ -28,7 +34,7 @@ class AuthorizeCommon(PaymentAcquirerCommon):
class AuthorizeForm(AuthorizeCommon):
def test_10_Authorize_form_render(self):
- self.assertEqual(self.authorize.environment, 'test', 'test without test environment')
+ self.assertEqual(self.authorize.state, 'test', 'test without test environment')
# ----------------------------------------
# Test: button direct rendering
@@ -92,7 +98,7 @@ class AuthorizeForm(AuthorizeCommon):
@mute_logger('odoo.addons.payment_authorize.models.payment', 'ValidationError')
def test_20_authorize_form_management(self):
# be sure not to do stupid thing
- self.assertEqual(self.authorize.environment, 'test', 'test without test environment')
+ self.assertEqual(self.authorize.state, 'test', 'test without test environment')
# typical data posted by authorize after client has successfully paid
authorize_post_data = {
@@ -183,7 +189,7 @@ class AuthorizeS2s(AuthorizeCommon):
def test_30_authorize_s2s(self):
# be sure not to do stupid thing
authorize = self.authorize
- self.assertEqual(authorize.environment, 'test', 'test without test environment')
+ self.assertEqual(authorize.state, 'test', 'test without test environment')
# add credential
# FIXME: put this test in master-nightly on odoo/odoo + create sandbox account
diff --git a/addons/payment_authorize/views/payment_authorize_templates.xml b/addons/payment_authorize/views/payment_authorize_templates.xml
index f0a8effa896..66f63bcb18c 100644
--- a/addons/payment_authorize/views/payment_authorize_templates.xml
+++ b/addons/payment_authorize/views/payment_authorize_templates.xml
@@ -53,7 +53,7 @@
<template id="authorize_s2s_form">
<input type="hidden" name="data_set" value="/payment/authorize/s2s/create_json_3ds"/>
<input type="hidden" name="acquirer_id" t-att-value="id"/>
- <input type="hidden" name="acquirer_environment" t-att-value="acq.environment"/>
+ <input type="hidden" name="acquirer_state" t-att-value="acq.state"/>
<input type="hidden" name="login_id" t-att-value="acq.sudo().authorize_login"/>
<input type="hidden" name="client_key" t-att-value="acq.sudo().authorize_client_key"/>
<input class="d-none" name="csrf_token" t-att-value="request.csrf_token()"/>
diff --git a/addons/payment_authorize/views/payment_views.xml b/addons/payment_authorize/views/payment_views.xml
index d2450222d3b..622c35b9608 100644
--- a/addons/payment_authorize/views/payment_views.xml
+++ b/addons/payment_authorize/views/payment_views.xml
@@ -7,9 +7,9 @@
<field name="arch" type="xml">
<xpath expr='//group[@name="acquirer"]' position='inside'>
<group attrs="{'invisible': [('provider', '!=', 'authorize')]}">
- <field name="authorize_login"/>
- <field name="authorize_transaction_key" password="True"/>
- <field name="authorize_signature_key" password="True"/>
+ <field name="authorize_login" attrs="{'required':[ ('provider', '=', 'authorize'), ('state', '!=', 'disabled')]}"/>
+ <field name="authorize_transaction_key" password="True" attrs="{'required':[ ('provider', '=', 'authorize'), ('state', '!=', 'disabled')]}"/>
+ <field name="authorize_signature_key" password="True" attrs="{'required':[ ('provider', '=', 'authorize'), ('state', '!=', 'disabled')]}"/>
<label for="authorize_client_key"/>
<div>
<field name="authorize_client_key" password="True"/>
diff --git a/addons/payment_buckaroo/data/payment_acquirer_data.xml b/addons/payment_buckaroo/data/payment_acquirer_data.xml
index 7b11d688844..d31b142aab1 100644
--- a/addons/payment_buckaroo/data/payment_acquirer_data.xml
+++ b/addons/payment_buckaroo/data/payment_acquirer_data.xml
@@ -8,11 +8,8 @@
<field name="provider">buckaroo</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="buckaroo_form"/>
- <field name="environment">test</field>
<field name="pre_msg"><![CDATA[
<p>You will be redirected to the Buckaroo website after clicking on the payment button.</p>]]></field>
- <field name="brq_websitekey">dummy</field>
- <field name="brq_secretkey">dummy</field>
</record>
</data>
diff --git a/addons/payment_buckaroo/models/payment.py b/addons/payment_buckaroo/models/payment.py
index 0936770ac9e..d0f9ed34741 100644
--- a/addons/payment_buckaroo/models/payment.py
+++ b/addons/payment_buckaroo/models/payment.py
@@ -89,7 +89,7 @@ class AcquirerBuckaroo(models.Model):
'Brq_amount': values['amount'],
'Brq_currency': values['currency'] and values['currency'].name or '',
'Brq_invoicenumber': values['reference'],
- 'brq_test': False if self.environment == 'prod' else True,
+ 'brq_test': True if self.state == 'test' else False,
'Brq_return': urls.url_join(base_url, BuckarooController._return_url),
'Brq_returncancel': urls.url_join(base_url, BuckarooController._cancel_url),
'Brq_returnerror': urls.url_join(base_url, BuckarooController._exception_url),
@@ -101,7 +101,9 @@ class AcquirerBuckaroo(models.Model):
return buckaroo_tx_values
def buckaroo_get_form_action_url(self):
- return self._get_buckaroo_urls(self.environment)['buckaroo_form_url']
+ self.ensure_one()
+ environment = 'prod' if self.state == 'enabled' else 'test'
+ return self._get_buckaroo_urls(environment)['buckaroo_form_url']
class TxBuckaroo(models.Model):
diff --git a/addons/payment_buckaroo/tests/test_buckaroo.py b/addons/payment_buckaroo/tests/test_buckaroo.py
index c78c998304d..926ac2cf059 100644
--- a/addons/payment_buckaroo/tests/test_buckaroo.py
+++ b/addons/payment_buckaroo/tests/test_buckaroo.py
@@ -17,7 +17,11 @@ class BuckarooCommon(PaymentAcquirerCommon):
super(BuckarooCommon, self).setUp()
# get the buckaroo account
self.buckaroo = self.env.ref('payment.payment_acquirer_buckaroo')
-
+ self.buckaroo.write({
+ 'brq_websitekey': 'dummy',
+ 'brq_secretkey': 'dummy',
+ 'state': 'test',
+ })
@odoo.tests.tagged('post_install', '-at_install', 'external', '-standard')
class BuckarooForm(BuckarooCommon):
@@ -25,7 +29,7 @@ class BuckarooForm(BuckarooCommon):
def test_10_Buckaroo_form_render(self):
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
# be sure not to do stupid things
- self.assertEqual(self.buckaroo.environment, 'test', 'test without test environment')
+ self.assertEqual(self.buckaroo.state, 'test', 'test without test environment')
# ----------------------------------------
# Test: button direct rendering
@@ -101,7 +105,7 @@ class BuckarooForm(BuckarooCommon):
@mute_logger('odoo.addons.payment_buckaroo.models.payment', 'ValidationError')
def test_20_buckaroo_form_management(self):
# be sure not to do stupid thing
- self.assertEqual(self.buckaroo.environment, 'test', 'test without test environment')
+ self.assertEqual(self.buckaroo.state, 'test', 'test without test environment')
# typical data posted by buckaroo after client has successfully paid
buckaroo_post_data = {
diff --git a/addons/payment_buckaroo/views/payment_views.xml b/addons/payment_buckaroo/views/payment_views.xml
index 1de4dd264fa..0bc66e52760 100644
--- a/addons/payment_buckaroo/views/payment_views.xml
+++ b/addons/payment_buckaroo/views/payment_views.xml
@@ -9,8 +9,8 @@
<field name="arch" type="xml">
<xpath expr='//group[@name="acquirer"]' position='inside'>
<group attrs="{'invisible': [('provider', '!=', 'buckaroo')]}">
- <field name="brq_websitekey"/>
- <field name="brq_secretkey"/>
+ <field name="brq_websitekey" attrs="{'required':[ ('provider', '=', 'buckaroo'), ('state', '!=', 'disabled')]}"/>
+ <field name="brq_secretkey" attrs="{'required':[ ('provider', '=', 'buckaroo'), ('state', '!=', 'disabled')]}"/>
</group>
</xpath>
</field>
diff --git a/addons/payment_ingenico/data/payment_acquirer_data.xml b/addons/payment_ingenico/data/payment_acquirer_data.xml
index b4700210f9b..10c2ca19742 100644
--- a/addons/payment_ingenico/data/payment_acquirer_data.xml
+++ b/addons/payment_ingenico/data/payment_acquirer_data.xml
@@ -4,19 +4,13 @@
<record id="payment.payment_acquirer_ingenico" model="payment.acquirer">
<field name="name">Ingenico</field>
- <field name="image_128" type="base64" file="payment_ogone/static/src/img/ogone_icon.png"/>
+ <field name="image_128" type="base64" file="payment_ingenico/static/src/img/ingenico_icon.png"/>
<field name="provider">ogone</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="ogone_form"/>
<field name="registration_view_template_id" ref="ogone_s2s_form"/>
- <field name="environment">test</field>
<field name="pre_msg"><![CDATA[
<p>You will be redirected to the Ingenico website after clicking on the payment button.</p>]]></field>
- <field name='ogone_pspid'>dummy</field>
- <field name='ogone_userid'>dummy</field>
- <field name='ogone_password'>dummy</field>
- <field name="ogone_shakey_in">dummy</field>
- <field name="ogone_shakey_out">dummy</field>
</record>
</data>
diff --git a/addons/payment_ingenico/models/payment.py b/addons/payment_ingenico/models/payment.py
index bc6fd9d3c74..fcc820e00fd 100644
--- a/addons/payment_ingenico/models/payment.py
+++ b/addons/payment_ingenico/models/payment.py
@@ -184,7 +184,9 @@ class PaymentAcquirerOgone(models.Model):
return ogone_tx_values
def ogone_get_form_action_url(self):
- return self._get_ogone_urls(self.environment)['ogone_standard_order_url']
+ self.ensure_one()
+ environment = 'prod' if self.state == 'enabled' else 'test'
+ return self._get_ogone_urls(environment)['ogone_standard_order_url']
def ogone_s2s_form_validate(self, data):
error = dict()
@@ -380,7 +382,7 @@ class PaymentTxOgone(models.Model):
data['SHASIGN'] = self.acquirer_id._ogone_generate_shasign('in', data)
- direct_order_url = 'https://secure.ogone.com/ncol/%s/orderdirect.asp' % (self.acquirer_id.environment)
+ direct_order_url = 'https://secure.ogone.com/ncol/%s/orderdirect.asp' % ('prod' if self.acquirer_id.state == 'enabled' else 'test')
logged_data = data.copy()
logged_data.pop('PSWD')
@@ -414,7 +416,7 @@ class PaymentTxOgone(models.Model):
}
data['SHASIGN'] = self.acquirer_id._ogone_generate_shasign('in', data)
- direct_order_url = 'https://secure.ogone.com/ncol/%s/maintenancedirect.asp' % (self.acquirer_id.environment)
+ direct_order_url = 'https://secure.ogone.com/ncol/%s/maintenancedirect.asp' % ('prod' if self.acquirer_id.state == 'enabled' else 'test')
logged_data = data.copy()
logged_data.pop('PSWD')
@@ -506,7 +508,7 @@ class PaymentTxOgone(models.Model):
'PSWD': account.ogone_password,
}
- query_direct_url = 'https://secure.ogone.com/ncol/%s/querydirect.asp' % (self.acquirer_id.environment)
+ query_direct_url = 'https://secure.ogone.com/ncol/%s/querydirect.asp' % ('prod' if self.acquirer_id.state == 'enabled' else 'test')
logged_data = data.copy()
logged_data.pop('PSWD')
@@ -553,7 +555,7 @@ class PaymentToken(models.Model):
'PROCESS_MODE': 'CHECKANDPROCESS',
}
- url = 'https://secure.ogone.com/ncol/%s/AFU_agree.asp' % (acquirer.environment,)
+ url = 'https://secure.ogone.com/ncol/%s/AFU_agree.asp' % ('prod' if self.acquirer_id.state == 'enabled' else 'test')
_logger.info("ogone_create: Creating new alias %s via url %s", alias, url)
result = requests.post(url, data=data).content
diff --git a/addons/payment_ingenico/tests/test_ogone.py b/addons/payment_ingenico/tests/test_ogone.py
index ea5c73018f3..09a25896796 100644
--- a/addons/payment_ingenico/tests/test_ogone.py
+++ b/addons/payment_ingenico/tests/test_ogone.py
@@ -17,11 +17,19 @@ class OgonePayment(PaymentAcquirerCommon):
super(OgonePayment, self).setUp()
self.ogone = self.env.ref('payment.payment_acquirer_ogone')
+ self.ogone.write({
+ 'ogone_pspid': 'dummy',
+ 'ogone_userid': 'dummy',
+ 'ogone_password': 'dummy',
+ 'ogone_shakey_in': 'dummy',
+ 'ogone_shakey_out': 'dummy',
+ 'state': 'test',
+ })
def test_10_ogone_form_render(self):
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
# be sure not to do stupid thing
- self.assertEqual(self.ogone.environment, 'test', 'test without test environment')
+ self.assertEqual(self.ogone.state, 'test', 'test without test environment')
# ----------------------------------------
# Test: button direct rendering + shasign
@@ -92,13 +100,13 @@ class OgonePayment(PaymentAcquirerCommon):
self.assertEqual(
form_input.get('value'),
form_values[form_input.get('name')],
- 'ogone: wrong value for form input %s: received %s instead of %s' % (form_input.get('name'), form_input.get('value'), form_values[form_input.get('name')])
+ 'ingenico: wrong value for form input %s: received %s instead of %s' % (form_input.get('name'), form_input.get('value'), form_values[form_input.get('name')])
)
@mute_logger('odoo.addons.payment_ingenico.models.payment', 'ValidationError')
def test_20_ogone_form_management(self):
# be sure not to do stupid thing
- self.assertEqual(self.ogone.environment, 'test', 'test without test environment')
+ self.assertEqual(self.ogone.state, 'test', 'test without test environment')
# typical data posted by ogone after client has successfully paid
ogone_post_data = {
@@ -161,7 +169,7 @@ class OgonePayment(PaymentAcquirerCommon):
def test_30_ogone_s2s(self):
test_ref = 'test_ref_%.15f' % time.time()
# be sure not to do stupid thing
- self.assertEqual(self.ogone.environment, 'test', 'test without test environment')
+ self.assertEqual(self.ogone.state, 'test', 'test without test environment')
# create a new draft tx
tx = self.env['payment.transaction'].create({
diff --git a/addons/payment_ingenico/views/payment_views.xml b/addons/payment_ingenico/views/payment_views.xml
index dbd4f27d6d8..82163fa6db6 100644
--- a/addons/payment_ingenico/views/payment_views.xml
+++ b/addons/payment_ingenico/views/payment_views.xml
@@ -9,11 +9,11 @@
<field name="arch" type="xml">
<xpath expr='//group[@name="acquirer"]' position='inside'>
<group attrs="{'invisible': [('provider', '!=', 'ogone')]}">
- <field name="ogone_pspid"/>
- <field name="ogone_userid"/>
- <field name="ogone_password"/>
- <field name="ogone_shakey_in"/>
- <field name="ogone_shakey_out"/>
+ <field name="ogone_pspid" attrs="{'required':[ ('provider', '=', 'ogone'), ('state', '!=', 'disabled')]}"/>
+ <field name="ogone_userid" attrs="{'required':[ ('provider', '=', 'ogone'), ('state', '!=', 'disabled')]}"/>
+ <field name="ogone_password" attrs="{'required':[ ('provider', '=', 'ogone'), ('state', '!=', 'disabled')]}"/>
+ <field name="ogone_shakey_in" attrs="{'required':[ ('provider', '=', 'ogone'), ('state', '!=', 'disabled')]}"/>
+ <field name="ogone_shakey_out" attrs="{'required':[ ('provider', '=', 'ogone'), ('state', '!=', 'disabled')]}"/>
<field name="ogone_alias_usage"/>
</group>
</xpath>
diff --git a/addons/payment_paypal/controllers/main.py b/addons/payment_paypal/controllers/main.py
index a3e87413747..f347973ad02 100644
--- a/addons/payment_paypal/controllers/main.py
+++ b/addons/payment_paypal/controllers/main.py
@@ -60,7 +60,7 @@ class PaypalController(http.Controller):
tx = None
if reference:
tx = request.env['payment.transaction'].search([('reference', '=', reference)])
- paypal_urls = request.env['payment.acquirer']._get_paypal_urls(tx and tx.acquirer_id.environment or 'prod')
+ paypal_urls = tx.acquirer_id.paypal_get_form_action_url()
pdt_request = bool(post.get('amt')) # check for spefific pdt param
if pdt_request:
# this means we are in PDT instead of DPN like before
diff --git a/addons/payment_paypal/data/payment_acquirer_data.xml b/addons/payment_paypal/data/payment_acquirer_data.xml
index 893feb51b6e..2bbd0b5bdbd 100644
--- a/addons/payment_paypal/data/payment_acquirer_data.xml
+++ b/addons/payment_paypal/data/payment_acquirer_data.xml
@@ -8,7 +8,6 @@
<field name="provider">paypal</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="paypal_form"/>
- <field name="environment">test</field>
<field name="pre_msg"><![CDATA[
<p>You will be redirected to the Paypal website after clicking on the payment button.</p>]]></field>
</record>
diff --git a/addons/payment_paypal/models/payment.py b/addons/payment_paypal/models/payment.py
index 8c0a8081d61..8d494eceaf3 100644
--- a/addons/payment_paypal/models/payment.py
+++ b/addons/payment_paypal/models/payment.py
@@ -20,7 +20,7 @@ class AcquirerPaypal(models.Model):
_inherit = 'payment.acquirer'
provider = fields.Selection(selection_add=[('paypal', 'Paypal')])
- paypal_email_account = fields.Char('Email', required_if_provider='paypal', groups='base.group_user', default=lambda self: self.env.user.email or 'dummy')
+ paypal_email_account = fields.Char('Email', required_if_provider='paypal', groups='base.group_user', default=lambda self: self.env.user.email or '')
paypal_seller_account = fields.Char(
'Merchant Account ID', groups='base.group_user',
help='The Merchant ID is used to ensure communications coming from Paypal are valid and secured.')
@@ -110,7 +110,9 @@ class AcquirerPaypal(models.Model):
return paypal_tx_values
def paypal_get_form_action_url(self):
- return self._get_paypal_urls(self.environment)['paypal_form_url']
+ self.ensure_one()
+ environment = 'prod' if self.state == 'enabled' else 'test'
+ return self._get_paypal_urls(environment)['paypal_form_url']
class TxPaypal(models.Model):
diff --git a/addons/payment_paypal/tests/test_paypal.py b/addons/payment_paypal/tests/test_paypal.py
index d7d2d93df1f..532d14f54ba 100644
--- a/addons/payment_paypal/tests/test_paypal.py
+++ b/addons/payment_paypal/tests/test_paypal.py
@@ -18,6 +18,10 @@ class PaypalCommon(PaymentAcquirerCommon):
super(PaypalCommon, self).setUp()
self.paypal = self.env.ref('payment.payment_acquirer_paypal')
+ self.paypal.write({
+ 'paypal_email_account': 'dummy',
+ 'state': 'test',
+ })
# some CC
self.amex = (('378282246310005', '123'), ('371449635398431', '123'))
@@ -39,7 +43,7 @@ class PaypalForm(PaypalCommon):
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
# be sure not to do stupid things
self.paypal.write({'paypal_email_account': 'tde+paypal-facilitator@odoo.com', 'fees_active': False})
- self.assertEqual(self.paypal.environment, 'test', 'test without test environment')
+ self.assertEqual(self.paypal.state, 'test', 'test without test environment')
# ----------------------------------------
# Test: button direct rendering
@@ -88,7 +92,7 @@ class PaypalForm(PaypalCommon):
def test_11_paypal_form_with_fees(self):
# be sure not to do stupid things
- self.assertEqual(self.paypal.environment, 'test', 'test without test environment')
+ self.assertEqual(self.paypal.state, 'test', 'test without test environment')
# update acquirer: compute fees
self.paypal.write({
@@ -120,7 +124,7 @@ class PaypalForm(PaypalCommon):
@mute_logger('odoo.addons.payment_paypal.models.payment', 'ValidationError')
def test_20_paypal_form_management(self):
# be sure not to do stupid things
- self.assertEqual(self.paypal.environment, 'test', 'test without test environment')
+ self.assertEqual(self.paypal.state, 'test', 'test without test environment')
# typical data posted by paypal after client has successfully paid
paypal_post_data = {
diff --git a/addons/payment_paypal/views/payment_views.xml b/addons/payment_paypal/views/payment_views.xml
index 47aed65bae8..43a8e47d4eb 100644
--- a/addons/payment_paypal/views/payment_views.xml
+++ b/addons/payment_paypal/views/payment_views.xml
@@ -9,10 +9,10 @@
<field name="arch" type="xml">
<xpath expr='//group[@name="acquirer"]' position='inside'>
<group attrs="{'invisible': [('provider', '!=', 'paypal')]}">
- <field name="paypal_email_account"/>
- <field name="paypal_seller_account"/>
- <field name="paypal_pdt_token"/>
- <field name="paypal_use_ipn"/>
+ <field name="paypal_email_account" attrs="{'required':[ ('provider', '=', 'paypal'), ('state', '!=', 'disabled')]}"/>
+ <field name="paypal_seller_account" attrs="{'required':[ ('provider', '=', 'paypal'), ('state', '!=', 'disabled')]}"/>
+ <field name="paypal_pdt_token" attrs="{'required':[ ('provider', '=', 'paypal'), ('state', '!=', 'disabled')]}"/>
+ <field name="paypal_use_ipn" attrs="{'required':[ ('provider', '=', 'paypal'), ('state', '!=', 'disabled')]}"/>
<a colspan="2" href="https://www.odoo.com/documentation/user/online/ecommerce/shopper_experience/paypal.html" target="_blank">How to configure your paypal account?</a>
</group>
</xpath>
diff --git a/addons/payment_payulatam/data/payment_acquirer_data.xml b/addons/payment_payulatam/data/payment_acquirer_data.xml
index 0dabaa42ac3..76381203ae5 100644
--- a/addons/payment_payulatam/data/payment_acquirer_data.xml
+++ b/addons/payment_payulatam/data/payment_acquirer_data.xml
@@ -5,13 +5,9 @@
<field name="provider">payulatam</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="payulatam_form"/>
- <field name="environment">test</field>
<field name="pre_msg" type="html">
<p>You will be redirected to the PayU Latam website after clicking on the payment button.</p>
</field>
- <field name="payulatam_account_id">dummy</field>
- <field name="payulatam_merchant_id">dummy</field>
- <field name="payulatam_api_key">dummy</field>
</record>
</data>
</odoo>
diff --git a/addons/payment_payulatam/models/payment.py b/addons/payment_payulatam/models/payment.py
index e6d69b55d03..db063f2ce5d 100644
--- a/addons/payment_payulatam/models/payment.py
+++ b/addons/payment_payulatam/models/payment.py
@@ -66,7 +66,8 @@ class PaymentAcquirerPayulatam(models.Model):
def payulatam_get_form_action_url(self):
self.ensure_one()
- return self._get_payulatam_urls(self.environment)
+ environment = 'prod' if self.state == 'enabled' else 'test'
+ return self._get_payulatam_urls(environment)
class PaymentTransactionPayulatam(models.Model):
diff --git a/addons/payment_payulatam/tests/test_payulatam.py b/addons/payment_payulatam/tests/test_payulatam.py
index 6722dcee059..063eccac584 100644
--- a/addons/payment_payulatam/tests/test_payulatam.py
+++ b/addons/payment_payulatam/tests/test_payulatam.py
@@ -12,6 +12,12 @@ class PayUlatamCommon(PaymentAcquirerCommon):
def setUp(self):
super(PayUlatamCommon, self).setUp()
self.payulatam = self.env.ref('payment.payment_acquirer_payulatam')
+ self.payulatam.write({
+ 'payulatam_account_id': 'dummy',
+ 'payulatam_merchant_id': 'dummy',
+ 'payulatam_api_key': 'dummy',
+ 'state': 'test',
+ })
@tagged('post_install', '-at_install', 'external', '-standard')
@@ -19,7 +25,7 @@ class PayUlatamForm(PayUlatamCommon):
def test_10_payulatam_form_render(self):
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
- self.assertEqual(self.payulatam.environment, 'test', 'test without test environment')
+ self.assertEqual(self.payulatam.state, 'test', 'test without test environment')
self.payulatam.write({
'payulatam_merchant_id': 'dummy',
'payulatam_account_id': 'dummy',
@@ -71,7 +77,7 @@ class PayUlatamForm(PayUlatamCommon):
)
def test_20_payulatam_form_management(self):
- self.assertEqual(self.payulatam.environment, 'test', 'test without test environment')
+ self.assertEqual(self.payulatam.state, 'test', 'test without test environment')
# typical data posted by payulatam after client has successfully paid
payulatam_post_data = {
diff --git a/addons/payment_payumoney/data/payment_acquirer_data.xml b/addons/payment_payumoney/data/payment_acquirer_data.xml
index dab5726f043..3190f4b2203 100644
--- a/addons/payment_payumoney/data/payment_acquirer_data.xml
+++ b/addons/payment_payumoney/data/payment_acquirer_data.xml
@@ -7,12 +7,9 @@
<field name="provider">payumoney</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="payumoney_form"/>
- <field name="environment">test</field>
<field name="pre_msg"><![CDATA[
<p>You will be redirected to the PayUmoney website after clicking on the payment button.</p>]]>
</field>
- <field name="payumoney_merchant_key">dummy</field>
- <field name="payumoney_merchant_salt">dummy</field>
</record>
</data>
</odoo>
diff --git a/addons/payment_payumoney/models/payment.py b/addons/payment_payumoney/models/payment.py
index d174f9bc997..202e4bd1d72 100644
--- a/addons/payment_payumoney/models/payment.py
+++ b/addons/payment_payumoney/models/payment.py
@@ -75,7 +75,8 @@ class PaymentAcquirerPayumoney(models.Model):
def payumoney_get_form_action_url(self):
self.ensure_one()
- return self._get_payumoney_urls(self.environment)['payumoney_form_url']
+ environment = 'prod' if self.state == 'enabled' else 'test'
+ return self._get_payumoney_urls(environment)['payumoney_form_url']
class PaymentTransactionPayumoney(models.Model):
diff --git a/addons/payment_payumoney/views/payment_views.xml b/addons/payment_payumoney/views/payment_views.xml
index 5156f0cb696..ce2a72d19d4 100644
--- a/addons/payment_payumoney/views/payment_views.xml
+++ b/addons/payment_payumoney/views/payment_views.xml
@@ -7,8 +7,8 @@
<field name="arch" type="xml">
<xpath expr='//group[@name="acquirer"]' position='inside'>
<group attrs="{'invisible': [('provider', '!=', 'payumoney')]}">
- <field name="payumoney_merchant_key"/>
- <field name="payumoney_merchant_salt" password="True"/>
+ <field name="payumoney_merchant_key" attrs="{'required':[ ('provider', '=', 'payumoney'), ('state', '!=', 'disabled')]}"/>
+ <field name="payumoney_merchant_salt" attrs="{'required':[ ('provider', '=', 'payumoney'), ('state', '!=', 'disabled')]}" password="True"/>
</group>
</xpath>
</field>
diff --git a/addons/payment_sips/data/payment_acquirer_data.xml b/addons/payment_sips/data/payment_acquirer_data.xml
index 666c0271ad6..2df9cf83216 100644
--- a/addons/payment_sips/data/payment_acquirer_data.xml
+++ b/addons/payment_sips/data/payment_acquirer_data.xml
@@ -8,11 +8,8 @@
<field name="provider">sips</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="payment_sips.sips_form"/>
- <field name="environment">test</field>
<field name="pre_msg"><![CDATA[
<p>You will be redirected to the Sips website after clicking on payment button.</p>]]></field>
- <field name="sips_merchant_id">****</field>
- <field name="sips_secret">****</field>
</record>
</data>
diff --git a/addons/payment_sips/models/payment.py b/addons/payment_sips/models/payment.py
index d4eefabf89c..7d37cf93c36 100644
--- a/addons/payment_sips/models/payment.py
+++ b/addons/payment_sips/models/payment.py
@@ -60,7 +60,7 @@ class AcquirerSips(models.Model):
# Test key provided by Worldine
key = u'002001000000001_KEY1'
- if self.environment == 'prod':
+ if self.state == 'enabled':
key = getattr(self, 'sips_secret')
shasign = sha256((data + key).encode('utf-8'))
@@ -74,7 +74,7 @@ class AcquirerSips(models.Model):
if not currency_code:
raise ValidationError(_('Currency not supported by Wordline'))
amount = int(values['amount'] * 100)
- if self.environment == 'prod':
+ if self.state == 'enabled':
# For production environment, key version 2 is required
merchant_id = getattr(self, 'sips_merchant_id')
key_version = self.env['ir.config_parameter'].sudo().get_param('sips.key_version', '2')
@@ -108,7 +108,7 @@ class AcquirerSips(models.Model):
def sips_get_form_action_url(self):
self.ensure_one()
- return self.environment == 'prod' and self.sips_prod_url or self.sips_test_url
+ return self.state == 'enabled' and self.sips_prod_url or self.sips_test_url
class TxSips(models.Model):
diff --git a/addons/payment_sips/views/payment_views.xml b/addons/payment_sips/views/payment_views.xml
index 00d9e51d445..bdd85f68132 100644
--- a/addons/payment_sips/views/payment_views.xml
+++ b/addons/payment_sips/views/payment_views.xml
@@ -9,11 +9,11 @@
<field name="arch" type="xml">
<xpath expr='//group[@name="acquirer"]' position='inside'>
<group attrs="{'invisible': [('provider', '!=', 'sips')]}">
- <field name="sips_merchant_id"/>
- <field name="sips_secret"/>
- <field name="sips_test_url"/>
- <field name="sips_prod_url"/>
- <field name="sips_version"/>
+ <field name="sips_merchant_id" attrs="{'required':[ ('provider', '=', 'sips'), ('state', '!=', 'disabled')]}"/>
+ <field name="sips_secret" attrs="{'required':[ ('provider', '=', 'sips'), ('state', '!=', 'disabled')]}"/>
+ <field name="sips_test_url" attrs="{'required':[ ('provider', '=', 'sips'), ('state', '!=', 'disabled')]}"/>
+ <field name="sips_prod_url" attrs="{'required':[ ('provider', '=', 'sips'), ('state', '!=', 'disabled')]}"/>
+ <field name="sips_version" attrs="{'required':[ ('provider', '=', 'sips'), ('state', '!=', 'disabled')]}"/>
</group>
</xpath>
</field>
diff --git a/addons/payment_stripe/data/payment_acquirer_data.xml b/addons/payment_stripe/data/payment_acquirer_data.xml
index 2d30e4c6a72..dab6ad9b50d 100644
--- a/addons/payment_stripe/data/payment_acquirer_data.xml
+++ b/addons/payment_stripe/data/payment_acquirer_data.xml
@@ -8,11 +8,8 @@
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="stripe_form"/>
<field name="registration_view_template_id" ref="stripe_s2s_form"/>
- <field name="environment">test</field>
<field name="pre_msg"><![CDATA[
<p>You will be prompted with Stripe Payment page for payment information.</p>]]></field>
- <field name="stripe_secret_key">dummy</field>
- <field name="stripe_publishable_key">dummy</field>
</record>
</data>
</odoo>
diff --git a/addons/payment_stripe/tests/test_stripe.py b/addons/payment_stripe/tests/test_stripe.py
index 1ef883de93f..4a7c0764bca 100644
--- a/addons/payment_stripe/tests/test_stripe.py
+++ b/addons/payment_stripe/tests/test_stripe.py
@@ -10,13 +10,18 @@ class StripeCommon(PaymentAcquirerCommon):
def setUp(self):
super(StripeCommon, self).setUp()
self.stripe = self.env.ref('payment.payment_acquirer_stripe')
+ self.stripe.write({
+ 'stripe_secret_key': 'dummy',
+ 'stripe_publishable_key': 'dummy',
+ 'state': 'test',
+ })
@odoo.tests.tagged('post_install', '-at_install', '-standard', 'external')
class StripeTest(StripeCommon):
def test_10_stripe_s2s(self):
- self.assertEqual(self.stripe.environment, 'test', 'test without test environment')
+ self.assertEqual(self.stripe.state, 'test', 'test without test environment')
# Add Stripe credentials
self.stripe.write({
@@ -51,7 +56,7 @@ class StripeTest(StripeCommon):
self.assertEqual(tx.state, 'done', 'Stripe: Transcation has been discarded.')
def test_20_stripe_form_render(self):
- self.assertEqual(self.stripe.environment, 'test', 'test without test environment')
+ self.assertEqual(self.stripe.state, 'test', 'test without test environment')
# ----------------------------------------
# Test: button direct rendering
@@ -63,7 +68,7 @@ class StripeTest(StripeCommon):
self.assertIn(self.buyer_values.get('partner_email'), res, 'Stripe: email input not found in rendered template')
def test_30_stripe_form_management(self):
- self.assertEqual(self.stripe.environment, 'test', 'test without test environment')
+ self.assertEqual(self.stripe.state, 'test', 'test without test environment')
# typical data posted by Stripe after client has successfully paid
stripe_post_data = {
diff --git a/addons/payment_stripe/views/payment_views.xml b/addons/payment_stripe/views/payment_views.xml
index ac649d11a8e..b66c75c71cc 100644
--- a/addons/payment_stripe/views/payment_views.xml
+++ b/addons/payment_stripe/views/payment_views.xml
@@ -7,8 +7,8 @@
<field name="arch" type="xml">
<xpath expr='//group[@name="acquirer"]' position='inside'>
<group attrs="{'invisible': [('provider', '!=', 'stripe')]}">
- <field name="stripe_secret_key" password="True"/>
- <field name="stripe_publishable_key" password="True"/>
+ <field name="stripe_secret_key" attrs="{'required':[ ('provider', '=', 'stripe'), ('state', '!=', 'disabled')]}" password="True"/>
+ <field name="stripe_publishable_key" attrs="{'required':[ ('provider', '=', 'stripe'), ('state', '!=', 'disabled')]}" password="True"/>
</group>
</xpath>
<xpath expr='//group[@name="acquirer_config"]' position='after'>
diff --git a/addons/payment_transfer/data/payment_acquirer_data.xml b/addons/payment_transfer/data/payment_acquirer_data.xml
index 5f060de7057..47f4986778b 100644
--- a/addons/payment_transfer/data/payment_acquirer_data.xml
+++ b/addons/payment_transfer/data/payment_acquirer_data.xml
@@ -6,10 +6,9 @@
<field name="name">Wire Transfer</field>
<field name="image_128" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/>
<field name="provider">transfer</field>
+ <field name="state">enabled</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="transfer_form"/>
- <field name="environment">test</field>
- <field name="website_published" eval="True"/>
<field name="pre_msg"><![CDATA[
<p>Transfer information will be provided when clicking 'Pay Now'.</p>]]>
</field>
diff --git a/addons/sale/controllers/portal.py b/addons/sale/controllers/portal.py
index 3adb5067f91..7d0ee178db2 100644
--- a/addons/sale/controllers/portal.py
+++ b/addons/sale/controllers/portal.py
@@ -175,7 +175,7 @@ class CustomerPortal(CustomerPortal):
if order_sudo.has_to_be_paid():
domain = expression.AND([
- ['&', ('website_published', '=', True), ('company_id', '=', order_sudo.company_id.id)],
+ ['&', ('state', 'in', ['enabled', 'test']), ('company_id', '=', order_sudo.company_id.id)],
['|', ('country_ids', '=', False), ('country_ids', 'in', [order_sudo.partner_id.country_id.id])]
])
acquirers = request.env['payment.acquirer'].sudo().search(domain)
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index f3f470a718f..14a25fd6685 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -839,7 +839,7 @@ class WebsiteSale(http.Controller):
)
domain = expression.AND([
- ['&', ('website_published', '=', True), ('company_id', '=', order.company_id.id)],
+ ['&', ('state', 'in', ['enabled', 'test']), ('company_id', '=', order.company_id.id)],
['|', ('website_id', '=', False), ('website_id', '=', request.website.id)],
['|', ('country_ids', '=', False), ('country_ids', 'in', [order.partner_id.country_id.id])]
])