See the merge commit for more details. task-2333042 Co-authored-by: Antoine Vandevenne <anv@odoo.com>
25 lines
897 B
Python
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."))
|