[FIX] payment_test: allow to disable it

closes odoo/odoo#37621

Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
This commit is contained in:
Damien Bouvy
2019-09-30 15:11:18 +00:00
parent ad94c1e712
commit d69ded69cc
@@ -14,13 +14,13 @@ class PaymentAcquirerTest(models.Model):
@api.model
def create(self, values):
if values.get('provider') == 'test' and 'state' in values and values.get('state') != 'test':
raise exceptions.UserError(_('This acquirer should not be used for other purpose than testing.'))
if values.get('provider') == 'test' and 'state' in values and values.get('state') not in ('test', 'disabled'):
raise exceptions.UserError(_('This acquirer should not be used for other purposes than testing.'))
return super(PaymentAcquirerTest, self).create(values)
def write(self, values):
if any(rec.provider == 'test' for rec in self) and 'state' in values and values.get('state') != 'test':
raise exceptions.UserError(_('This acquirer should not be used for other purpose than testing.'))
if any(rec.provider == 'test' for rec in self) and 'state' in values and values.get('state') not in ('test', 'disabled'):
raise exceptions.UserError(_('This acquirer should not be used for other purposes than testing.'))
return super(PaymentAcquirerTest, self).write(values)
@api.model