[IMP] payment(_*): activate default payment methods

When user enables or tests payment provider it will automatically
enable most used payment method in that provider.

closes odoo/odoo#140907

Signed-off-by: anko-odoo <anko@odoo.com>
This commit is contained in:
Anita (anko)
2023-11-06 18:11:32 +00:00
parent f7a4da5602
commit 06523ff675
31 changed files with 316 additions and 17 deletions
+12
View File
@@ -1,5 +1,17 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# The codes of the payment methods to activate when Authorize is activated.
DEFAULT_PAYMENT_METHODS_CODES = [
# Primary payment methods.
'ach_direct_debit',
'card',
# Brand payment methods.
'visa',
'mastercard',
'amex',
'discover',
]
# Mapping of payment method codes to Authorize codes.
PAYMENT_METHODS_MAPPING = {
'amex': 'americanexpress',
@@ -8,6 +8,7 @@ from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.fields import Command
from odoo.addons.payment_authorize import const
from odoo.addons.payment_authorize.models.authorize_request import AuthorizeAPI
_logger = logging.getLogger(__name__)
@@ -121,3 +122,10 @@ class PaymentProvider(models.Model):
'client_key': self.authorize_client_key,
}
return json.dumps(inline_form_values)
def _get_default_payment_method_codes(self):
""" Override of `payment` to return the default payment method codes. """
default_codes = super()._get_default_payment_method_codes()
if self.code != 'authorize':
return default_codes
return const.DEFAULT_PAYMENT_METHODS_CODES