Files
odoo_source/addons/payment_test/models/payment_acquirer.py
T
Arnaud JosetandAntoine Vandevenne 71c5278d9a [REF] payment_test: migrate the Test acquirer to the new payment API
See the merge commit for more details.

task-2333042

Co-authored-by: Antoine Vandevenne <anv@odoo.com>
2021-03-30 09:25:51 +02:00

25 lines
897 B
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, api, fields, models
from odoo.exceptions import UserError
class PaymentAcquirer(models.Model):
_inherit = 'payment.acquirer'
provider = fields.Selection(selection_add=[('test', 'Test')], ondelete={'test': 'set default'})
@api.depends('provider')
def _compute_view_configuration_fields(self):
""" Override of payment to hide the credentials page.
:return: None
"""
super()._compute_view_configuration_fields()
self.filtered(lambda acq: acq.provider == 'test').show_credentials_page = False
@api.constrains('state', 'provider')
def _check_acquirer_state(self):
if self.filtered(lambda a: a.provider == 'test' and a.state not in ('test', 'disabled')):
raise UserError(_("Test acquirers should never be enabled."))