From 4d6bd1ce335daae250c7f2cce90af05a4319fb40 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 22 Aug 2022 18:22:04 +0200 Subject: [PATCH] [REF] payment_*: adapt to payment changes --- addons/payment_adyen/__init__.py | 6 +++++- addons/payment_adyen/__manifest__.py | 1 + .../payment_adyen/data/payment_acquirer_data.xml | 6 ------ addons/payment_adyen/models/__init__.py | 1 - .../payment_adyen/models/account_payment_method.py | 14 -------------- addons/payment_adyen/models/payment_acquirer.py | 6 ------ addons/payment_adyen/tests/common.py | 4 ++-- addons/payment_alipay/__init__.py | 14 +++++++++----- addons/payment_alipay/__manifest__.py | 1 + .../payment_alipay/data/payment_acquirer_data.xml | 6 ------ addons/payment_alipay/models/__init__.py | 1 - .../models/account_payment_method.py | 14 -------------- addons/payment_alipay/models/payment_acquirer.py | 6 ------ addons/payment_alipay/tests/common.py | 4 ++-- addons/payment_aps/__init__.py | 6 +++++- addons/payment_aps/__manifest__.py | 1 + addons/payment_aps/data/payment_acquirer_data.xml | 6 ------ addons/payment_aps/models/__init__.py | 1 - .../payment_aps/models/account_payment_method.py | 13 ------------- addons/payment_aps/models/payment_acquirer.py | 6 ------ addons/payment_aps/tests/common.py | 4 ++-- addons/payment_asiapay/__init__.py | 6 +++++- addons/payment_asiapay/__manifest__.py | 1 + .../payment_asiapay/data/payment_acquirer_data.xml | 6 ------ addons/payment_asiapay/models/__init__.py | 1 - .../models/account_payment_method.py | 13 ------------- addons/payment_asiapay/models/payment_acquirer.py | 6 ------ addons/payment_asiapay/tests/common.py | 4 ++-- addons/payment_authorize/__init__.py | 6 +++++- addons/payment_authorize/__manifest__.py | 1 + .../data/payment_acquirer_data.xml | 6 ------ addons/payment_authorize/models/__init__.py | 1 - .../models/account_payment_method.py | 14 -------------- .../payment_authorize/models/payment_acquirer.py | 6 ------ addons/payment_authorize/tests/common.py | 4 ++-- addons/payment_buckaroo/__init__.py | 6 +++++- addons/payment_buckaroo/__manifest__.py | 1 + .../data/payment_acquirer_data.xml | 6 ------ addons/payment_buckaroo/models/__init__.py | 1 - .../models/account_payment_method.py | 14 -------------- addons/payment_buckaroo/models/payment_acquirer.py | 6 ------ addons/payment_buckaroo/tests/common.py | 4 ++-- addons/payment_custom/__init__.py | 6 +++++- addons/payment_custom/__manifest__.py | 1 + addons/payment_custom/models/payment_acquirer.py | 11 ++++++++++- addons/payment_demo/__init__.py | 6 +++++- addons/payment_demo/__manifest__.py | 1 + addons/payment_demo/data/payment_acquirer_data.xml | 6 ------ addons/payment_demo/models/__init__.py | 1 - .../payment_demo/models/account_payment_method.py | 14 -------------- addons/payment_demo/models/payment_acquirer.py | 6 ------ addons/payment_demo/tests/common.py | 4 ++-- addons/payment_flutterwave/__init__.py | 6 +++++- addons/payment_flutterwave/__manifest__.py | 1 + .../data/payment_acquirer_data.xml | 6 ------ addons/payment_flutterwave/models/__init__.py | 1 - .../models/account_payment_method.py | 13 ------------- .../payment_flutterwave/models/payment_acquirer.py | 6 ------ addons/payment_flutterwave/tests/common.py | 4 ++-- addons/payment_mercado_pago/__init__.py | 6 +++++- addons/payment_mercado_pago/__manifest__.py | 1 + .../data/payment_acquirer_data.xml | 6 ------ addons/payment_mercado_pago/models/__init__.py | 1 - .../models/account_payment_method.py | 14 -------------- .../models/payment_acquirer.py | 7 ------- addons/payment_mercado_pago/tests/common.py | 4 ++-- addons/payment_mollie/__init__.py | 6 +++++- addons/payment_mollie/__manifest__.py | 1 + .../payment_mollie/data/payment_acquirer_data.xml | 6 ------ addons/payment_mollie/models/__init__.py | 1 - .../models/account_payment_method.py | 13 ------------- addons/payment_mollie/models/payment_acquirer.py | 6 ------ addons/payment_mollie/tests/common.py | 4 ++-- addons/payment_ogone/__init__.py | 14 +++++++++----- addons/payment_ogone/__manifest__.py | 1 + .../payment_ogone/data/payment_acquirer_data.xml | 6 ------ addons/payment_ogone/models/__init__.py | 1 - .../payment_ogone/models/account_payment_method.py | 14 -------------- addons/payment_ogone/models/payment_acquirer.py | 6 ------ addons/payment_ogone/tests/common.py | 4 ++-- addons/payment_ogone/tests/test_ogone.py | 3 +++ addons/payment_paypal/__init__.py | 6 +++++- addons/payment_paypal/__manifest__.py | 1 + .../payment_paypal/data/payment_acquirer_data.xml | 6 ------ addons/payment_paypal/models/__init__.py | 1 - .../models/account_payment_method.py | 14 -------------- addons/payment_paypal/models/payment_acquirer.py | 6 ------ addons/payment_paypal/tests/common.py | 4 ++-- addons/payment_payulatam/__init__.py | 14 +++++++++----- addons/payment_payulatam/__manifest__.py | 1 + .../data/payment_acquirer_data.xml | 6 ------ addons/payment_payulatam/models/__init__.py | 1 - .../models/account_payment_method.py | 14 -------------- .../payment_payulatam/models/payment_acquirer.py | 6 ------ addons/payment_payulatam/tests/common.py | 4 ++-- addons/payment_payulatam/tests/test_payulatam.py | 3 +++ addons/payment_payumoney/__init__.py | 14 +++++++++----- addons/payment_payumoney/__manifest__.py | 1 + .../data/payment_acquirer_data.xml | 6 ------ addons/payment_payumoney/models/__init__.py | 1 - .../models/account_payment_method.py | 14 -------------- .../payment_payumoney/models/payment_acquirer.py | 6 ------ addons/payment_payumoney/tests/common.py | 4 ++-- addons/payment_razorpay/__init__.py | 6 +++++- addons/payment_razorpay/__manifest__.py | 1 + .../data/payment_acquirer_data.xml | 6 ------ addons/payment_razorpay/models/__init__.py | 1 - .../models/account_payment_method.py | 13 ------------- addons/payment_razorpay/models/payment_acquirer.py | 6 ------ addons/payment_razorpay/tests/common.py | 4 ++-- addons/payment_sips/__init__.py | 6 +++++- addons/payment_sips/__manifest__.py | 1 + addons/payment_sips/data/payment_acquirer_data.xml | 6 ------ addons/payment_sips/models/__init__.py | 1 - .../payment_sips/models/account_payment_method.py | 14 -------------- addons/payment_sips/models/payment_acquirer.py | 6 ------ addons/payment_sips/tests/common.py | 4 ++-- addons/payment_stripe/__init__.py | 6 +++++- addons/payment_stripe/__manifest__.py | 1 + .../payment_stripe/data/payment_acquirer_data.xml | 6 ------ addons/payment_stripe/models/__init__.py | 1 - .../models/account_payment_method.py | 14 -------------- addons/payment_stripe/models/payment_acquirer.py | 13 ++++++------- addons/payment_stripe/tests/common.py | 4 ++-- 124 files changed, 180 insertions(+), 525 deletions(-) delete mode 100644 addons/payment_adyen/models/account_payment_method.py delete mode 100644 addons/payment_alipay/models/account_payment_method.py delete mode 100644 addons/payment_aps/models/account_payment_method.py delete mode 100644 addons/payment_asiapay/models/account_payment_method.py delete mode 100644 addons/payment_authorize/models/account_payment_method.py delete mode 100644 addons/payment_buckaroo/models/account_payment_method.py delete mode 100644 addons/payment_demo/models/account_payment_method.py delete mode 100644 addons/payment_flutterwave/models/account_payment_method.py delete mode 100644 addons/payment_mercado_pago/models/account_payment_method.py delete mode 100644 addons/payment_mollie/models/account_payment_method.py delete mode 100644 addons/payment_ogone/models/account_payment_method.py delete mode 100644 addons/payment_paypal/models/account_payment_method.py delete mode 100644 addons/payment_payulatam/models/account_payment_method.py delete mode 100644 addons/payment_payumoney/models/account_payment_method.py delete mode 100644 addons/payment_razorpay/models/account_payment_method.py delete mode 100644 addons/payment_sips/models/account_payment_method.py delete mode 100644 addons/payment_stripe/models/account_payment_method.py diff --git a/addons/payment_adyen/__init__.py b/addons/payment_adyen/__init__.py index 7627ceef542..c4373c48351 100644 --- a/addons/payment_adyen/__init__.py +++ b/addons/payment_adyen/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'adyen') def uninstall_hook(cr, registry): diff --git a/addons/payment_adyen/__manifest__.py b/addons/payment_adyen/__manifest__.py index daea33f3801..399a57a0790 100644 --- a/addons/payment_adyen/__manifest__.py +++ b/addons/payment_adyen/__manifest__.py @@ -15,6 +15,7 @@ 'data/payment_acquirer_data.xml', # Depends on views/payment_adyen_templates.xml ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'assets': { 'web.assets_frontend': [ diff --git a/addons/payment_adyen/data/payment_acquirer_data.xml b/addons/payment_adyen/data/payment_acquirer_data.xml index 4166c024d69..43d5825a194 100644 --- a/addons/payment_adyen/data/payment_acquirer_data.xml +++ b/addons/payment_adyen/data/payment_acquirer_data.xml @@ -7,10 +7,4 @@ True - - Adyen - adyen - inbound - - diff --git a/addons/payment_adyen/models/__init__.py b/addons/payment_adyen/models/__init__.py index 2303108a7c9..22eb69117db 100644 --- a/addons/payment_adyen/models/__init__.py +++ b/addons/payment_adyen/models/__init__.py @@ -1,6 +1,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_token from . import payment_transaction diff --git a/addons/payment_adyen/models/account_payment_method.py b/addons/payment_adyen/models/account_payment_method.py deleted file mode 100644 index e5344413810..00000000000 --- a/addons/payment_adyen/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['adyen'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_adyen/models/payment_acquirer.py b/addons/payment_adyen/models/payment_acquirer.py index dcd025238d6..7fb514f53c3 100644 --- a/addons/payment_adyen/models/payment_acquirer.py +++ b/addons/payment_adyen/models/payment_acquirer.py @@ -140,12 +140,6 @@ class PaymentAcquirer(models.Model): """ return f'ODOO_PARTNER_{partner_id}' - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'adyen': - return super()._get_default_payment_method_id() - return self.env.ref('payment_adyen.payment_method_adyen').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('adyen', [ diff --git a/addons/payment_adyen/tests/common.py b/addons/payment_adyen/tests/common.py index 5503bbb2337..260f0c131ec 100644 --- a/addons/payment_adyen/tests/common.py +++ b/addons/payment_adyen/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class AdyenCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.adyen = cls._prepare_acquirer('adyen', update_values={ 'adyen_merchant_account': 'dummy', diff --git a/addons/payment_alipay/__init__.py b/addons/payment_alipay/__init__.py index fa22c2f7cfd..62adfb612c1 100644 --- a/addons/payment_alipay/__init__.py +++ b/addons/payment_alipay/__init__.py @@ -6,11 +6,7 @@ from . import models from odoo.exceptions import UserError from odoo.tools import config -from odoo.addons.payment import reset_payment_acquirer - - -def uninstall_hook(cr, registry): - reset_payment_acquirer(cr, registry, 'alipay') +from odoo.addons.payment import setup_provider, reset_payment_acquirer def pre_init_hook(cr): @@ -18,3 +14,11 @@ def pre_init_hook(cr): raise UserError( "This module is deprecated and cannot be installed. " "Consider installing the Payment Acquirer: AsiaPay module instead.") + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'alipay') + + +def uninstall_hook(cr, registry): + reset_payment_acquirer(cr, registry, 'alipay') diff --git a/addons/payment_alipay/__manifest__.py b/addons/payment_alipay/__manifest__.py index cfca0e80ee2..6b91bd3afcf 100644 --- a/addons/payment_alipay/__manifest__.py +++ b/addons/payment_alipay/__manifest__.py @@ -14,6 +14,7 @@ ], 'application': False, 'pre_init_hook': 'pre_init_hook', + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_alipay/data/payment_acquirer_data.xml b/addons/payment_alipay/data/payment_acquirer_data.xml index b3fefb04584..d5eaf738029 100644 --- a/addons/payment_alipay/data/payment_acquirer_data.xml +++ b/addons/payment_alipay/data/payment_acquirer_data.xml @@ -19,10 +19,4 @@ - - Alipay - alipay - inbound - - diff --git a/addons/payment_alipay/models/__init__.py b/addons/payment_alipay/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_alipay/models/__init__.py +++ b/addons/payment_alipay/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_alipay/models/account_payment_method.py b/addons/payment_alipay/models/account_payment_method.py deleted file mode 100644 index ca552ea1014..00000000000 --- a/addons/payment_alipay/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['alipay'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_alipay/models/payment_acquirer.py b/addons/payment_alipay/models/payment_acquirer.py index 0d735ac9fb4..1877364b649 100644 --- a/addons/payment_alipay/models/payment_acquirer.py +++ b/addons/payment_alipay/models/payment_acquirer.py @@ -69,12 +69,6 @@ class PaymentAcquirer(models.Model): else: # test environment return 'https://openapi.alipaydev.com/gateway.do' - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'alipay': - return super()._get_default_payment_method_id() - return self.env.ref('payment_alipay.payment_method_alipay').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('alipay', [ diff --git a/addons/payment_alipay/tests/common.py b/addons/payment_alipay/tests/common.py index 7e4ba8d83af..c90c25683dc 100644 --- a/addons/payment_alipay/tests/common.py +++ b/addons/payment_alipay/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class AlipayCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.currency_yuan = cls._prepare_currency('CNY') cls.alipay = cls._prepare_acquirer('alipay', update_values={ diff --git a/addons/payment_aps/__init__.py b/addons/payment_aps/__init__.py index 49548e95279..822ce26b728 100644 --- a/addons/payment_aps/__init__.py +++ b/addons/payment_aps/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'aps') def uninstall_hook(cr, registry): diff --git a/addons/payment_aps/__manifest__.py b/addons/payment_aps/__manifest__.py index cc741c45e48..d8c74c53812 100644 --- a/addons/payment_aps/__manifest__.py +++ b/addons/payment_aps/__manifest__.py @@ -14,6 +14,7 @@ 'data/payment_acquirer_data.xml', ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_aps/data/payment_acquirer_data.xml b/addons/payment_aps/data/payment_acquirer_data.xml index 7348d23c17b..309aca76b5e 100644 --- a/addons/payment_aps/data/payment_acquirer_data.xml +++ b/addons/payment_aps/data/payment_acquirer_data.xml @@ -6,10 +6,4 @@ - - Amazon Payment Services - aps - inbound - - diff --git a/addons/payment_aps/models/__init__.py b/addons/payment_aps/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_aps/models/__init__.py +++ b/addons/payment_aps/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_aps/models/account_payment_method.py b/addons/payment_aps/models/account_payment_method.py deleted file mode 100644 index 6e44846a42e..00000000000 --- a/addons/payment_aps/models/account_payment_method.py +++ /dev/null @@ -1,13 +0,0 @@ -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['aps'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_aps/models/payment_acquirer.py b/addons/payment_aps/models/payment_acquirer.py index 2e23149ceac..76ec94d7ff8 100644 --- a/addons/payment_aps/models/payment_acquirer.py +++ b/addons/payment_aps/models/payment_acquirer.py @@ -59,12 +59,6 @@ class PaymentAcquirer(models.Model): signing_string = ''.join([key, sign_data, key]) return hashlib.sha256(signing_string.encode()).hexdigest() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'aps': - return super()._get_default_payment_method_id() - return self.env.ref('payment_aps.payment_method_aps').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('aps', [ diff --git a/addons/payment_aps/tests/common.py b/addons/payment_aps/tests/common.py index 9062a6d9bfd..ea47894d799 100644 --- a/addons/payment_aps/tests/common.py +++ b/addons/payment_aps/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.http_common import PaymentHttpCommon class APSCommon(PaymentHttpCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.aps = cls._prepare_acquirer('aps', update_values={ 'aps_merchant_identifier': '123456abc', diff --git a/addons/payment_asiapay/__init__.py b/addons/payment_asiapay/__init__.py index d98b3099c48..46141320e71 100644 --- a/addons/payment_asiapay/__init__.py +++ b/addons/payment_asiapay/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'asiapay') def uninstall_hook(cr, registry): diff --git a/addons/payment_asiapay/__manifest__.py b/addons/payment_asiapay/__manifest__.py index 48246e595ec..3682ae68dd3 100644 --- a/addons/payment_asiapay/__manifest__.py +++ b/addons/payment_asiapay/__manifest__.py @@ -15,6 +15,7 @@ 'data/payment_acquirer_data.xml', ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_asiapay/data/payment_acquirer_data.xml b/addons/payment_asiapay/data/payment_acquirer_data.xml index 07d9c2da913..b62859e97f9 100644 --- a/addons/payment_asiapay/data/payment_acquirer_data.xml +++ b/addons/payment_asiapay/data/payment_acquirer_data.xml @@ -6,10 +6,4 @@ - - AsiaPay - asiapay - inbound - - diff --git a/addons/payment_asiapay/models/__init__.py b/addons/payment_asiapay/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_asiapay/models/__init__.py +++ b/addons/payment_asiapay/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_asiapay/models/account_payment_method.py b/addons/payment_asiapay/models/account_payment_method.py deleted file mode 100644 index d13f5f059f6..00000000000 --- a/addons/payment_asiapay/models/account_payment_method.py +++ /dev/null @@ -1,13 +0,0 @@ -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['asiapay'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_asiapay/models/payment_acquirer.py b/addons/payment_asiapay/models/payment_acquirer.py index ef172577ec1..8c06fd97a4e 100644 --- a/addons/payment_asiapay/models/payment_acquirer.py +++ b/addons/payment_asiapay/models/payment_acquirer.py @@ -86,12 +86,6 @@ class PaymentAcquirer(models.Model): shasign.update(signing_string.encode()) return shasign.hexdigest() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'asiapay': - return super()._get_default_payment_method_id() - return self.env.ref('payment_asiapay.payment_method_asiapay').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('asiapay', [ diff --git a/addons/payment_asiapay/tests/common.py b/addons/payment_asiapay/tests/common.py index 4a92d2a05e0..8d4c747b7de 100644 --- a/addons/payment_asiapay/tests/common.py +++ b/addons/payment_asiapay/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class AsiaPayCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.asiapay = cls._prepare_acquirer('asiapay', update_values={ 'asiapay_merchant_id': '123456789', diff --git a/addons/payment_authorize/__init__.py b/addons/payment_authorize/__init__.py index 22957034603..810262e33bd 100644 --- a/addons/payment_authorize/__init__.py +++ b/addons/payment_authorize/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'authorize') def uninstall_hook(cr, registry): diff --git a/addons/payment_authorize/__manifest__.py b/addons/payment_authorize/__manifest__.py index baa2d1c1d65..b80b10459aa 100644 --- a/addons/payment_authorize/__manifest__.py +++ b/addons/payment_authorize/__manifest__.py @@ -14,6 +14,7 @@ 'data/payment_acquirer_data.xml', ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'assets': { 'web.assets_frontend': [ diff --git a/addons/payment_authorize/data/payment_acquirer_data.xml b/addons/payment_authorize/data/payment_acquirer_data.xml index fac5cb334d3..4dc5252e44d 100644 --- a/addons/payment_authorize/data/payment_acquirer_data.xml +++ b/addons/payment_authorize/data/payment_acquirer_data.xml @@ -7,10 +7,4 @@ True - - Authorize.Net - authorize - inbound - - diff --git a/addons/payment_authorize/models/__init__.py b/addons/payment_authorize/models/__init__.py index 2303108a7c9..22eb69117db 100644 --- a/addons/payment_authorize/models/__init__.py +++ b/addons/payment_authorize/models/__init__.py @@ -1,6 +1,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_token from . import payment_transaction diff --git a/addons/payment_authorize/models/account_payment_method.py b/addons/payment_authorize/models/account_payment_method.py deleted file mode 100644 index bf78f232f43..00000000000 --- a/addons/payment_authorize/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['authorize'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_authorize/models/payment_acquirer.py b/addons/payment_authorize/models/payment_acquirer.py index 312070ca3c7..8b3807b2001 100644 --- a/addons/payment_authorize/models/payment_acquirer.py +++ b/addons/payment_authorize/models/payment_acquirer.py @@ -146,12 +146,6 @@ class PaymentAcquirer(models.Model): return self.authorize_currency_id - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'authorize': - return super()._get_default_payment_method_id() - return self.env.ref('payment_authorize.payment_method_authorize').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('authorize', [ diff --git a/addons/payment_authorize/tests/common.py b/addons/payment_authorize/tests/common.py index dfef348cf41..2cd2de70236 100644 --- a/addons/payment_authorize/tests/common.py +++ b/addons/payment_authorize/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class AuthorizeCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.authorize = cls._prepare_acquirer('authorize', update_values={ 'authorize_login': 'dummy', diff --git a/addons/payment_buckaroo/__init__.py b/addons/payment_buckaroo/__init__.py index 5b385b2d908..7759f4ff380 100644 --- a/addons/payment_buckaroo/__init__.py +++ b/addons/payment_buckaroo/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'buckaroo') def uninstall_hook(cr, registry): diff --git a/addons/payment_buckaroo/__manifest__.py b/addons/payment_buckaroo/__manifest__.py index 253fd6e9561..fd93e00a95c 100644 --- a/addons/payment_buckaroo/__manifest__.py +++ b/addons/payment_buckaroo/__manifest__.py @@ -14,6 +14,7 @@ 'data/payment_acquirer_data.xml', ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_buckaroo/data/payment_acquirer_data.xml b/addons/payment_buckaroo/data/payment_acquirer_data.xml index 862874eab69..99baf35e525 100644 --- a/addons/payment_buckaroo/data/payment_acquirer_data.xml +++ b/addons/payment_buckaroo/data/payment_acquirer_data.xml @@ -6,10 +6,4 @@ - - Buckaroo - buckaroo - inbound - - diff --git a/addons/payment_buckaroo/models/__init__.py b/addons/payment_buckaroo/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_buckaroo/models/__init__.py +++ b/addons/payment_buckaroo/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_buckaroo/models/account_payment_method.py b/addons/payment_buckaroo/models/account_payment_method.py deleted file mode 100644 index 68b5d007c78..00000000000 --- a/addons/payment_buckaroo/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['buckaroo'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_buckaroo/models/payment_acquirer.py b/addons/payment_buckaroo/models/payment_acquirer.py index 61c2277bac1..cd2938d1b9b 100644 --- a/addons/payment_buckaroo/models/payment_acquirer.py +++ b/addons/payment_buckaroo/models/payment_acquirer.py @@ -64,12 +64,6 @@ class PaymentAcquirer(models.Model): # Calculate the SHA-1 hash over the signing string return sha1(sign_string.encode('utf-8')).hexdigest() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'buckaroo': - return super()._get_default_payment_method_id() - return self.env.ref('payment_buckaroo.payment_method_buckaroo').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('buckaroo', ['buckaroo_website_key', 'buckaroo_secret_key']) diff --git a/addons/payment_buckaroo/tests/common.py b/addons/payment_buckaroo/tests/common.py index b25f71030af..4442332f1d6 100644 --- a/addons/payment_buckaroo/tests/common.py +++ b/addons/payment_buckaroo/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class BuckarooCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.buckaroo = cls._prepare_acquirer('buckaroo', update_values={ 'buckaroo_website_key': 'dummy', diff --git a/addons/payment_custom/__init__.py b/addons/payment_custom/__init__.py index 4637f9c6cb8..9c84098cb5b 100644 --- a/addons/payment_custom/__init__.py +++ b/addons/payment_custom/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'transfer') def uninstall_hook(cr, registry): diff --git a/addons/payment_custom/__manifest__.py b/addons/payment_custom/__manifest__.py index 1143d2ff776..72953480369 100644 --- a/addons/payment_custom/__manifest__.py +++ b/addons/payment_custom/__manifest__.py @@ -16,6 +16,7 @@ 'payment_custom/static/src/js/post_processing.js', ], }, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_custom/models/payment_acquirer.py b/addons/payment_custom/models/payment_acquirer.py index a65c759cd0f..8da9c7903e1 100644 --- a/addons/payment_custom/models/payment_acquirer.py +++ b/addons/payment_custom/models/payment_acquirer.py @@ -39,7 +39,16 @@ class PaymentAcquirer(models.Model): }) def _transfer_ensure_pending_msg_is_set(self): - for acquirer in self.filtered(lambda a: a.provider == 'custom' and not a.pending_msg): + transfer_acquirers_without_msg = self.filtered( + lambda a: a.provider == 'custom' and not a.pending_msg) + if not transfer_acquirers_without_msg: + return + + account_payment = self.env['ir.module.module']._get('account_payment') + if account_payment.state != 'installed': + return + + for acquirer in transfer_acquirers_without_msg: company_id = acquirer.company_id.id # filter only bank accounts marked as visible accounts = self.env['account.journal'].search([ diff --git a/addons/payment_demo/__init__.py b/addons/payment_demo/__init__.py index 088dd07d7f0..cf89d92d877 100644 --- a/addons/payment_demo/__init__.py +++ b/addons/payment_demo/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'test') def uninstall_hook(cr, registry): diff --git a/addons/payment_demo/__manifest__.py b/addons/payment_demo/__manifest__.py index edfdf76726c..7abb5b6de00 100644 --- a/addons/payment_demo/__manifest__.py +++ b/addons/payment_demo/__manifest__.py @@ -16,6 +16,7 @@ It should never be used in production environment. Make sure to disable it befor 'views/payment_transaction_views.xml', 'data/payment_acquirer_data.xml', ], + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'assets': { 'web.assets_frontend': [ diff --git a/addons/payment_demo/data/payment_acquirer_data.xml b/addons/payment_demo/data/payment_acquirer_data.xml index 503d01563e3..911f72593b7 100644 --- a/addons/payment_demo/data/payment_acquirer_data.xml +++ b/addons/payment_demo/data/payment_acquirer_data.xml @@ -8,10 +8,4 @@ True - - Demo - demo - inbound - - diff --git a/addons/payment_demo/models/__init__.py b/addons/payment_demo/models/__init__.py index 2303108a7c9..22eb69117db 100644 --- a/addons/payment_demo/models/__init__.py +++ b/addons/payment_demo/models/__init__.py @@ -1,6 +1,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_token from . import payment_transaction diff --git a/addons/payment_demo/models/account_payment_method.py b/addons/payment_demo/models/account_payment_method.py deleted file mode 100644 index 3655a59cedc..00000000000 --- a/addons/payment_demo/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['demo'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_demo/models/payment_acquirer.py b/addons/payment_demo/models/payment_acquirer.py index 4f1393f31f3..831f6c89e7e 100644 --- a/addons/payment_demo/models/payment_acquirer.py +++ b/addons/payment_demo/models/payment_acquirer.py @@ -36,9 +36,3 @@ class PaymentAcquirer(models.Model): def _check_acquirer_state(self): if self.filtered(lambda a: a.provider == 'demo' and a.state not in ('test', 'disabled')): raise UserError(_("Demo acquirers should never be enabled.")) - - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'demo': - return super()._get_default_payment_method_id() - return self.env.ref('payment_demo.payment_method_demo').id diff --git a/addons/payment_demo/tests/common.py b/addons/payment_demo/tests/common.py index c8e4e4bb98b..7e5c3be0acf 100644 --- a/addons/payment_demo/tests/common.py +++ b/addons/payment_demo/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class PaymentDemoCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.acquirer = cls._prepare_acquirer(provider='demo') diff --git a/addons/payment_flutterwave/__init__.py b/addons/payment_flutterwave/__init__.py index 14fae20949e..44a39b3dcc3 100644 --- a/addons/payment_flutterwave/__init__.py +++ b/addons/payment_flutterwave/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'flutterwave') def uninstall_hook(cr, registry): diff --git a/addons/payment_flutterwave/__manifest__.py b/addons/payment_flutterwave/__manifest__.py index 3e8b3fc61c5..d7fde60258b 100644 --- a/addons/payment_flutterwave/__manifest__.py +++ b/addons/payment_flutterwave/__manifest__.py @@ -15,6 +15,7 @@ 'data/payment_acquirer_data.xml', ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_flutterwave/data/payment_acquirer_data.xml b/addons/payment_flutterwave/data/payment_acquirer_data.xml index fc23febe681..70b1bd20082 100644 --- a/addons/payment_flutterwave/data/payment_acquirer_data.xml +++ b/addons/payment_flutterwave/data/payment_acquirer_data.xml @@ -7,10 +7,4 @@ True - - Flutterwave - flutterwave - inbound - - diff --git a/addons/payment_flutterwave/models/__init__.py b/addons/payment_flutterwave/models/__init__.py index 2303108a7c9..22eb69117db 100644 --- a/addons/payment_flutterwave/models/__init__.py +++ b/addons/payment_flutterwave/models/__init__.py @@ -1,6 +1,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_token from . import payment_transaction diff --git a/addons/payment_flutterwave/models/account_payment_method.py b/addons/payment_flutterwave/models/account_payment_method.py deleted file mode 100644 index a641b6e5215..00000000000 --- a/addons/payment_flutterwave/models/account_payment_method.py +++ /dev/null @@ -1,13 +0,0 @@ -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['flutterwave'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_flutterwave/models/payment_acquirer.py b/addons/payment_flutterwave/models/payment_acquirer.py index fc3ffc48143..45401822649 100644 --- a/addons/payment_flutterwave/models/payment_acquirer.py +++ b/addons/payment_flutterwave/models/payment_acquirer.py @@ -100,12 +100,6 @@ class PaymentAcquirer(models.Model): ) return response.json() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'flutterwave': - return super()._get_default_payment_method_id() - return self.env.ref('payment_flutterwave.payment_method_flutterwave').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('flutterwave', [ diff --git a/addons/payment_flutterwave/tests/common.py b/addons/payment_flutterwave/tests/common.py index a0f449f84f8..a618f739b08 100644 --- a/addons/payment_flutterwave/tests/common.py +++ b/addons/payment_flutterwave/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class FlutterwaveCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.flutterwave = cls._prepare_acquirer('flutterwave', update_values={ 'flutterwave_public_key': 'FLWPUBK_TEST-abcdef-X', diff --git a/addons/payment_mercado_pago/__init__.py b/addons/payment_mercado_pago/__init__.py index 982a588f8cf..c568e29f9be 100644 --- a/addons/payment_mercado_pago/__init__.py +++ b/addons/payment_mercado_pago/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'mercado_pago') def uninstall_hook(cr, registry): diff --git a/addons/payment_mercado_pago/__manifest__.py b/addons/payment_mercado_pago/__manifest__.py index 700fe52967d..fa63319d009 100644 --- a/addons/payment_mercado_pago/__manifest__.py +++ b/addons/payment_mercado_pago/__manifest__.py @@ -15,6 +15,7 @@ 'data/payment_acquirer_data.xml', # Depends on views/payment_mercado_pago_templates.xml ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_mercado_pago/data/payment_acquirer_data.xml b/addons/payment_mercado_pago/data/payment_acquirer_data.xml index 53fae97a5e2..bdb58aeaad0 100644 --- a/addons/payment_mercado_pago/data/payment_acquirer_data.xml +++ b/addons/payment_mercado_pago/data/payment_acquirer_data.xml @@ -6,10 +6,4 @@ - - Mercado Pago - mercado_pago - inbound - - diff --git a/addons/payment_mercado_pago/models/__init__.py b/addons/payment_mercado_pago/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_mercado_pago/models/__init__.py +++ b/addons/payment_mercado_pago/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_mercado_pago/models/account_payment_method.py b/addons/payment_mercado_pago/models/account_payment_method.py deleted file mode 100644 index 1abd3a5e9e9..00000000000 --- a/addons/payment_mercado_pago/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['mercado_pago'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_mercado_pago/models/payment_acquirer.py b/addons/payment_mercado_pago/models/payment_acquirer.py index 06af0ab1dcb..320dd61ccbf 100644 --- a/addons/payment_mercado_pago/models/payment_acquirer.py +++ b/addons/payment_mercado_pago/models/payment_acquirer.py @@ -81,13 +81,6 @@ class PaymentAcquirer(models.Model): ) return response.json() - def _get_default_payment_method_id(self): - self.ensure_one() - - if self.provider != 'mercado_pago': - return super()._get_default_payment_method_id() - return self.env.ref('payment_mercado_pago.payment_method_mercado_pago').id - def _neutralize(self): super()._neutralize() diff --git a/addons/payment_mercado_pago/tests/common.py b/addons/payment_mercado_pago/tests/common.py index 528ccde43ed..0f7b75c9fe2 100644 --- a/addons/payment_mercado_pago/tests/common.py +++ b/addons/payment_mercado_pago/tests/common.py @@ -8,8 +8,8 @@ class MercadoPagoCommon(PaymentCommon): MP_PAYMENT_ID = '1234567890' @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.acquirer = cls._prepare_acquirer('mercado_pago', update_values={ 'mercado_pago_access_token': 'TEST-4850554046279901-TEST-TEST', diff --git a/addons/payment_mollie/__init__.py b/addons/payment_mollie/__init__.py index 6a2229be8da..ac70cbd0ab1 100755 --- a/addons/payment_mollie/__init__.py +++ b/addons/payment_mollie/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'mollie') def uninstall_hook(cr, registry): diff --git a/addons/payment_mollie/__manifest__.py b/addons/payment_mollie/__manifest__.py index 0240166bcfc..8383d1e41bc 100755 --- a/addons/payment_mollie/__manifest__.py +++ b/addons/payment_mollie/__manifest__.py @@ -18,6 +18,7 @@ 'data/payment_acquirer_data.xml', ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3' } diff --git a/addons/payment_mollie/data/payment_acquirer_data.xml b/addons/payment_mollie/data/payment_acquirer_data.xml index 369fbe7ba00..960d2fd1da4 100755 --- a/addons/payment_mollie/data/payment_acquirer_data.xml +++ b/addons/payment_mollie/data/payment_acquirer_data.xml @@ -6,10 +6,4 @@ - - Mollie - mollie - inbound - - diff --git a/addons/payment_mollie/models/__init__.py b/addons/payment_mollie/models/__init__.py index 28c8703fcc1..8e04237423a 100755 --- a/addons/payment_mollie/models/__init__.py +++ b/addons/payment_mollie/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_mollie/models/account_payment_method.py b/addons/payment_mollie/models/account_payment_method.py deleted file mode 100644 index 031618f3f17..00000000000 --- a/addons/payment_mollie/models/account_payment_method.py +++ /dev/null @@ -1,13 +0,0 @@ -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['mollie'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_mollie/models/payment_acquirer.py b/addons/payment_mollie/models/payment_acquirer.py index 23c6c862198..0153d29bddf 100755 --- a/addons/payment_mollie/models/payment_acquirer.py +++ b/addons/payment_mollie/models/payment_acquirer.py @@ -38,12 +38,6 @@ class PaymentAcquirer(models.Model): return acquirers - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'mollie': - return super()._get_default_payment_method_id() - return self.env.ref('payment_mollie.payment_method_mollie').id - def _mollie_make_request(self, endpoint, data=None, method='POST'): """ Make a request at mollie endpoint. diff --git a/addons/payment_mollie/tests/common.py b/addons/payment_mollie/tests/common.py index 2290f8d242c..d1084a920d2 100644 --- a/addons/payment_mollie/tests/common.py +++ b/addons/payment_mollie/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class MollieCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.mollie = cls._prepare_acquirer('mollie', update_values={ 'mollie_api_key': 'dummy', diff --git a/addons/payment_ogone/__init__.py b/addons/payment_ogone/__init__.py index 8889ff91560..fd4140e823c 100644 --- a/addons/payment_ogone/__init__.py +++ b/addons/payment_ogone/__init__.py @@ -6,11 +6,7 @@ from . import models from odoo.exceptions import UserError from odoo.tools import config -from odoo.addons.payment import reset_payment_acquirer - - -def uninstall_hook(cr, registry): - reset_payment_acquirer(cr, registry, 'ogone') +from odoo.addons.payment import setup_provider, reset_payment_acquirer def pre_init_hook(cr): @@ -18,3 +14,11 @@ def pre_init_hook(cr): raise UserError( "This module is deprecated and cannot be installed. " "Consider installing the Payment Acquirer: Stripe module instead.") + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'ogone') + + +def uninstall_hook(cr, registry): + reset_payment_acquirer(cr, registry, 'ogone') diff --git a/addons/payment_ogone/__manifest__.py b/addons/payment_ogone/__manifest__.py index 9c27ab8c796..0a07ee5f199 100644 --- a/addons/payment_ogone/__manifest__.py +++ b/addons/payment_ogone/__manifest__.py @@ -14,6 +14,7 @@ ], 'application': False, 'pre_init_hook': 'pre_init_hook', + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_ogone/data/payment_acquirer_data.xml b/addons/payment_ogone/data/payment_acquirer_data.xml index db388a667b2..6d49b64c6cb 100644 --- a/addons/payment_ogone/data/payment_acquirer_data.xml +++ b/addons/payment_ogone/data/payment_acquirer_data.xml @@ -21,10 +21,4 @@ True - - Ogone - ogone - inbound - - diff --git a/addons/payment_ogone/models/__init__.py b/addons/payment_ogone/models/__init__.py index 2303108a7c9..22eb69117db 100644 --- a/addons/payment_ogone/models/__init__.py +++ b/addons/payment_ogone/models/__init__.py @@ -1,6 +1,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_token from . import payment_transaction diff --git a/addons/payment_ogone/models/account_payment_method.py b/addons/payment_ogone/models/account_payment_method.py deleted file mode 100644 index 2dcb8174c66..00000000000 --- a/addons/payment_ogone/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['ogone'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_ogone/models/payment_acquirer.py b/addons/payment_ogone/models/payment_acquirer.py index 3f58482e903..877bfb8fb77 100644 --- a/addons/payment_ogone/models/payment_acquirer.py +++ b/addons/payment_ogone/models/payment_acquirer.py @@ -132,12 +132,6 @@ class PaymentAcquirer(models.Model): raise ValidationError("Ogone: " + _("The communication with the API failed.")) return response.content - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'ogone': - return super()._get_default_payment_method_id() - return self.env.ref('payment_ogone.payment_method_ogone').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('ogone', [ diff --git a/addons/payment_ogone/tests/common.py b/addons/payment_ogone/tests/common.py index 82079feffe6..21f0495b93b 100644 --- a/addons/payment_ogone/tests/common.py +++ b/addons/payment_ogone/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class OgoneCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.ogone = cls._prepare_acquirer('ogone', update_values={ 'ogone_pspid': 'dummy', diff --git a/addons/payment_ogone/tests/test_ogone.py b/addons/payment_ogone/tests/test_ogone.py index fd44ddfdc12..4930f484573 100644 --- a/addons/payment_ogone/tests/test_ogone.py +++ b/addons/payment_ogone/tests/test_ogone.py @@ -45,6 +45,9 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): @freeze_time('2011-11-02 12:00:21') # Freeze time for consistent singularization behavior def test_reference_is_computed_based_on_document_name(self): """ Test computation of reference prefixes based on the provided invoice. """ + if not self.env['ir.module.module']._get('account').state == 'installed': + self.skipTest('account module not installed') + invoice = self.env['account.move'].create({}) reference = self.env['payment.transaction']._compute_reference( self.ogone.provider, invoice_ids=[Command.set([invoice.id])] diff --git a/addons/payment_paypal/__init__.py b/addons/payment_paypal/__init__.py index bb623f55af5..cfd8988924d 100644 --- a/addons/payment_paypal/__init__.py +++ b/addons/payment_paypal/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'paypal') def uninstall_hook(cr, registry): diff --git a/addons/payment_paypal/__manifest__.py b/addons/payment_paypal/__manifest__.py index c22a67264ac..ebafedd33ed 100644 --- a/addons/payment_paypal/__manifest__.py +++ b/addons/payment_paypal/__manifest__.py @@ -15,6 +15,7 @@ 'data/payment_paypal_email_data.xml', ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_paypal/data/payment_acquirer_data.xml b/addons/payment_paypal/data/payment_acquirer_data.xml index 78aea6590b7..645b3cff567 100644 --- a/addons/payment_paypal/data/payment_acquirer_data.xml +++ b/addons/payment_paypal/data/payment_acquirer_data.xml @@ -6,10 +6,4 @@ - - Paypal - paypal - inbound - - diff --git a/addons/payment_paypal/models/__init__.py b/addons/payment_paypal/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_paypal/models/__init__.py +++ b/addons/payment_paypal/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_paypal/models/account_payment_method.py b/addons/payment_paypal/models/account_payment_method.py deleted file mode 100644 index 14df1f23d1e..00000000000 --- a/addons/payment_paypal/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['paypal'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_paypal/models/payment_acquirer.py b/addons/payment_paypal/models/payment_acquirer.py index 98cb25a674a..a7fd0059f81 100644 --- a/addons/payment_paypal/models/payment_acquirer.py +++ b/addons/payment_paypal/models/payment_acquirer.py @@ -78,12 +78,6 @@ class PaymentAcquirer(models.Model): } self.env['mail.mail'].sudo().create(mail_values).send() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'paypal': - return super()._get_default_payment_method_id() - return self.env.ref('payment_paypal.payment_method_paypal').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('paypal', [ diff --git a/addons/payment_paypal/tests/common.py b/addons/payment_paypal/tests/common.py index 738c207d3fc..5d35022ec9f 100644 --- a/addons/payment_paypal/tests/common.py +++ b/addons/payment_paypal/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class PaypalCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.paypal = cls._prepare_acquirer('paypal', update_values={ 'paypal_email_account': 'dummy@test.mail.com', diff --git a/addons/payment_payulatam/__init__.py b/addons/payment_payulatam/__init__.py index 4e664c65661..006bec2fbdd 100644 --- a/addons/payment_payulatam/__init__.py +++ b/addons/payment_payulatam/__init__.py @@ -6,11 +6,7 @@ from . import models from odoo.exceptions import UserError from odoo.tools import config -from odoo.addons.payment import reset_payment_acquirer - - -def uninstall_hook(cr, registry): - reset_payment_acquirer(cr, registry, 'payulatam') +from odoo.addons.payment import setup_provider, reset_payment_acquirer def pre_init_hook(cr): @@ -18,3 +14,11 @@ def pre_init_hook(cr): raise UserError( "This module is deprecated and cannot be installed. " "Consider installing the Payment Acquirer: Mercado Pago module instead.") + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'payulatam') + + +def uninstall_hook(cr, registry): + reset_payment_acquirer(cr, registry, 'payulatam') diff --git a/addons/payment_payulatam/__manifest__.py b/addons/payment_payulatam/__manifest__.py index a68ab042445..74314f7294e 100644 --- a/addons/payment_payulatam/__manifest__.py +++ b/addons/payment_payulatam/__manifest__.py @@ -14,6 +14,7 @@ ], 'application': False, 'pre_init_hook': 'pre_init_hook', + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_payulatam/data/payment_acquirer_data.xml b/addons/payment_payulatam/data/payment_acquirer_data.xml index 16d93d5b539..6148e9a9d9a 100644 --- a/addons/payment_payulatam/data/payment_acquirer_data.xml +++ b/addons/payment_payulatam/data/payment_acquirer_data.xml @@ -21,10 +21,4 @@ - - payulatam - payulatam - inbound - - diff --git a/addons/payment_payulatam/models/__init__.py b/addons/payment_payulatam/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_payulatam/models/__init__.py +++ b/addons/payment_payulatam/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_payulatam/models/account_payment_method.py b/addons/payment_payulatam/models/account_payment_method.py deleted file mode 100644 index 18139d1f690..00000000000 --- a/addons/payment_payulatam/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['payulatam'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_payulatam/models/payment_acquirer.py b/addons/payment_payulatam/models/payment_acquirer.py index e464dc92ee2..64ba73f03f9 100644 --- a/addons/payment_payulatam/models/payment_acquirer.py +++ b/addons/payment_payulatam/models/payment_acquirer.py @@ -69,12 +69,6 @@ class PaymentAcquirer(models.Model): ]) return md5(data_string.encode('utf-8')).hexdigest() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'payulatam': - return super()._get_default_payment_method_id() - return self.env.ref('payment_payulatam.payment_method_payulatam').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('payulatam', [ diff --git a/addons/payment_payulatam/tests/common.py b/addons/payment_payulatam/tests/common.py index c06eef0e0e0..741079e428f 100644 --- a/addons/payment_payulatam/tests/common.py +++ b/addons/payment_payulatam/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class PayULatamCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.payulatam = cls._prepare_acquirer('payulatam', update_values={ 'payulatam_account_id': 'dummy', diff --git a/addons/payment_payulatam/tests/test_payulatam.py b/addons/payment_payulatam/tests/test_payulatam.py index a358460a5c2..a9ba1978170 100644 --- a/addons/payment_payulatam/tests/test_payulatam.py +++ b/addons/payment_payulatam/tests/test_payulatam.py @@ -46,6 +46,9 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): @freeze_time('2011-11-02 12:00:21') # Freeze time for consistent singularization behavior def test_reference_is_computed_based_on_document_name(self): """ Test computation of reference prefixes based on the provided invoice. """ + if not self.env['ir.module.module']._get('account').state == 'installed': + self.skipTest('account module not installed') + invoice = self.env['account.move'].create({}) reference = self.env['payment.transaction']._compute_reference( self.payulatam.provider, invoice_ids=[Command.set([invoice.id])] diff --git a/addons/payment_payumoney/__init__.py b/addons/payment_payumoney/__init__.py index 00e70999271..81b5b91e5af 100644 --- a/addons/payment_payumoney/__init__.py +++ b/addons/payment_payumoney/__init__.py @@ -6,11 +6,7 @@ from . import models from odoo.exceptions import UserError from odoo.tools import config -from odoo.addons.payment import reset_payment_acquirer - - -def uninstall_hook(cr, registry): - reset_payment_acquirer(cr, registry, 'payumoney') +from odoo.addons.payment import setup_provider, reset_payment_acquirer def pre_init_hook(cr): @@ -18,3 +14,11 @@ def pre_init_hook(cr): raise UserError( "This module is deprecated and cannot be installed. " "Consider installing the Payment Acquirer: Razorpay module instead.") + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'payumoney') + + +def uninstall_hook(cr, registry): + reset_payment_acquirer(cr, registry, 'payumoney') diff --git a/addons/payment_payumoney/__manifest__.py b/addons/payment_payumoney/__manifest__.py index 52978eba73d..fa040a50963 100644 --- a/addons/payment_payumoney/__manifest__.py +++ b/addons/payment_payumoney/__manifest__.py @@ -14,6 +14,7 @@ ], 'application': False, 'pre_init_hook': 'pre_init_hook', + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_payumoney/data/payment_acquirer_data.xml b/addons/payment_payumoney/data/payment_acquirer_data.xml index 153cdf50fe5..f625fc6d4ce 100644 --- a/addons/payment_payumoney/data/payment_acquirer_data.xml +++ b/addons/payment_payumoney/data/payment_acquirer_data.xml @@ -21,10 +21,4 @@ - - PayUmoney - payumoney - inbound - - diff --git a/addons/payment_payumoney/models/__init__.py b/addons/payment_payumoney/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_payumoney/models/__init__.py +++ b/addons/payment_payumoney/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_payumoney/models/account_payment_method.py b/addons/payment_payumoney/models/account_payment_method.py deleted file mode 100644 index f440153ef1d..00000000000 --- a/addons/payment_payumoney/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['payumoney'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_payumoney/models/payment_acquirer.py b/addons/payment_payumoney/models/payment_acquirer.py index 2c7f912c800..3999d6262a4 100644 --- a/addons/payment_payumoney/models/payment_acquirer.py +++ b/addons/payment_payumoney/models/payment_acquirer.py @@ -50,12 +50,6 @@ class PaymentAcquirer(models.Model): sign = '|'.join(f'{sign_values.get(k) or ""}' for k in keys.split('|')) return hashlib.sha512(sign.encode('utf-8')).hexdigest() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'payumoney': - return super()._get_default_payment_method_id() - return self.env.ref('payment_payumoney.payment_method_payumoney').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('payumoney', ['payumoney_merchant_key', 'payumoney_merchant_salt']) diff --git a/addons/payment_payumoney/tests/common.py b/addons/payment_payumoney/tests/common.py index 9ef210dc8d3..2ada88da6ee 100644 --- a/addons/payment_payumoney/tests/common.py +++ b/addons/payment_payumoney/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class PayumoneyCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.payumoney = cls._prepare_acquirer('payumoney', update_values={ 'payumoney_merchant_key': 'dummy', diff --git a/addons/payment_razorpay/__init__.py b/addons/payment_razorpay/__init__.py index 141de1d6b73..48f85efd398 100644 --- a/addons/payment_razorpay/__init__.py +++ b/addons/payment_razorpay/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'payumoney') def uninstall_hook(cr, registry): diff --git a/addons/payment_razorpay/__manifest__.py b/addons/payment_razorpay/__manifest__.py index 00c9abcd51b..e0f9f1eb9df 100644 --- a/addons/payment_razorpay/__manifest__.py +++ b/addons/payment_razorpay/__manifest__.py @@ -14,6 +14,7 @@ 'data/payment_acquirer_data.xml', # Depends on views/payment_razorpay_templates.xml ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_razorpay/data/payment_acquirer_data.xml b/addons/payment_razorpay/data/payment_acquirer_data.xml index 65397ae27a6..b920f9e2ade 100644 --- a/addons/payment_razorpay/data/payment_acquirer_data.xml +++ b/addons/payment_razorpay/data/payment_acquirer_data.xml @@ -6,10 +6,4 @@ - - Razorpay - razorpay - inbound - - diff --git a/addons/payment_razorpay/models/__init__.py b/addons/payment_razorpay/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_razorpay/models/__init__.py +++ b/addons/payment_razorpay/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_razorpay/models/account_payment_method.py b/addons/payment_razorpay/models/account_payment_method.py deleted file mode 100644 index 7e364a300f6..00000000000 --- a/addons/payment_razorpay/models/account_payment_method.py +++ /dev/null @@ -1,13 +0,0 @@ -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['razorpay'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_razorpay/models/payment_acquirer.py b/addons/payment_razorpay/models/payment_acquirer.py index 3b90134a11b..f6324c5d2a4 100644 --- a/addons/payment_razorpay/models/payment_acquirer.py +++ b/addons/payment_razorpay/models/payment_acquirer.py @@ -122,12 +122,6 @@ class PaymentAcquirer(models.Model): secret = self.razorpay_webhook_secret return hmac.new(secret.encode(), msg=data, digestmod=hashlib.sha256).hexdigest() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'razorpay': - return super()._get_default_payment_method_id() - return self.env.ref('payment_razorpay.payment_method_razorpay').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('razorpay', [ diff --git a/addons/payment_razorpay/tests/common.py b/addons/payment_razorpay/tests/common.py index fb0a6d9c323..072ffe11497 100644 --- a/addons/payment_razorpay/tests/common.py +++ b/addons/payment_razorpay/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class RazorpayCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.acquirer = cls._prepare_acquirer('razorpay', update_values={ 'razorpay_key_id': 'rzp_123', diff --git a/addons/payment_sips/__init__.py b/addons/payment_sips/__init__.py index a4666ef725d..03b8bcc24ca 100644 --- a/addons/payment_sips/__init__.py +++ b/addons/payment_sips/__init__.py @@ -3,7 +3,11 @@ from . import models from . import controllers -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'sips') def uninstall_hook(cr, registry): diff --git a/addons/payment_sips/__manifest__.py b/addons/payment_sips/__manifest__.py index bcc120d33d6..e7796b9d030 100644 --- a/addons/payment_sips/__manifest__.py +++ b/addons/payment_sips/__manifest__.py @@ -19,6 +19,7 @@ not guaranteed.""", 'data/payment_acquirer_data.xml', ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'license': 'LGPL-3', } diff --git a/addons/payment_sips/data/payment_acquirer_data.xml b/addons/payment_sips/data/payment_acquirer_data.xml index f9954e2cf2f..c925eae871f 100644 --- a/addons/payment_sips/data/payment_acquirer_data.xml +++ b/addons/payment_sips/data/payment_acquirer_data.xml @@ -6,10 +6,4 @@ - - Sips - sips - inbound - - diff --git a/addons/payment_sips/models/__init__.py b/addons/payment_sips/models/__init__.py index 28c8703fcc1..8e04237423a 100644 --- a/addons/payment_sips/models/__init__.py +++ b/addons/payment_sips/models/__init__.py @@ -1,5 +1,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_transaction diff --git a/addons/payment_sips/models/account_payment_method.py b/addons/payment_sips/models/account_payment_method.py deleted file mode 100644 index ad8f59d4141..00000000000 --- a/addons/payment_sips/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['sips'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_sips/models/payment_acquirer.py b/addons/payment_sips/models/payment_acquirer.py index 2e4fe158c96..d60bb80d10b 100644 --- a/addons/payment_sips/models/payment_acquirer.py +++ b/addons/payment_sips/models/payment_acquirer.py @@ -55,12 +55,6 @@ class PaymentAcquirer(models.Model): shasign = sha256((data + key).encode('utf-8')) return shasign.hexdigest() - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'sips': - return super()._get_default_payment_method_id() - return self.env.ref('payment_sips.payment_method_sips').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('sips', ['sips_merchant_id', 'sips_secret']) diff --git a/addons/payment_sips/tests/common.py b/addons/payment_sips/tests/common.py index ca24662397c..48600f561f2 100644 --- a/addons/payment_sips/tests/common.py +++ b/addons/payment_sips/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class SipsCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.sips = cls._prepare_acquirer('sips', update_values={ 'sips_merchant_id': 'dummy_mid', diff --git a/addons/payment_stripe/__init__.py b/addons/payment_stripe/__init__.py index 72c8c7887ad..d4b3bb66954 100644 --- a/addons/payment_stripe/__init__.py +++ b/addons/payment_stripe/__init__.py @@ -3,7 +3,11 @@ from . import controllers from . import models -from odoo.addons.payment import reset_payment_acquirer +from odoo.addons.payment import setup_provider, reset_payment_acquirer + + +def post_init_hook(cr, registry): + setup_provider(cr, registry, 'stripe') def uninstall_hook(cr, registry): diff --git a/addons/payment_stripe/__manifest__.py b/addons/payment_stripe/__manifest__.py index 8d363de587c..9dfb180566f 100644 --- a/addons/payment_stripe/__manifest__.py +++ b/addons/payment_stripe/__manifest__.py @@ -15,6 +15,7 @@ 'data/payment_acquirer_data.xml', # Depends on views/payment_stripe_templates.xml ], 'application': True, + 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', 'assets': { 'web.assets_frontend': [ diff --git a/addons/payment_stripe/data/payment_acquirer_data.xml b/addons/payment_stripe/data/payment_acquirer_data.xml index 14a5043e44d..f9f25fef5da 100644 --- a/addons/payment_stripe/data/payment_acquirer_data.xml +++ b/addons/payment_stripe/data/payment_acquirer_data.xml @@ -8,10 +8,4 @@ True - - Stripe - stripe - inbound - - diff --git a/addons/payment_stripe/models/__init__.py b/addons/payment_stripe/models/__init__.py index 2303108a7c9..22eb69117db 100644 --- a/addons/payment_stripe/models/__init__.py +++ b/addons/payment_stripe/models/__init__.py @@ -1,6 +1,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_payment_method from . import payment_acquirer from . import payment_token from . import payment_transaction diff --git a/addons/payment_stripe/models/account_payment_method.py b/addons/payment_stripe/models/account_payment_method.py deleted file mode 100644 index 9f74eb9979e..00000000000 --- a/addons/payment_stripe/models/account_payment_method.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class AccountPaymentMethod(models.Model): - _inherit = 'account.payment.method' - - @api.model - def _get_payment_method_information(self): - res = super()._get_payment_method_information() - res['stripe'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]} - return res diff --git a/addons/payment_stripe/models/payment_acquirer.py b/addons/payment_stripe/models/payment_acquirer.py index 4666fd24169..ca2afd36309 100644 --- a/addons/payment_stripe/models/payment_acquirer.py +++ b/addons/payment_stripe/models/payment_acquirer.py @@ -109,7 +109,12 @@ class PaymentAcquirer(models.Model): connected_account = self._stripe_fetch_or_create_connected_account() # Link generation - menu_id = menu_id or self.env.ref('payment.payment_acquirer_menu').id + if not menu_id: + # Fall back on `account_payment`'s menu if it is installed. If not, the user is + # redirected to the acquirer's form view but without any menu in the breadcrumb. + menu = self.env.ref('account_payment.payment_acquirer_menu', False) + menu_id = menu and menu.id # Only set if `account_payment` is installed. + account_link_url = self._stripe_create_account_link(connected_account['id'], menu_id) if account_link_url: action = { @@ -259,12 +264,6 @@ class PaymentAcquirer(models.Model): """ return {} - def _get_default_payment_method_id(self): - self.ensure_one() - if self.provider != 'stripe': - return super()._get_default_payment_method_id() - return self.env.ref('payment_stripe.payment_method_stripe').id - def _neutralize(self): super()._neutralize() self._neutralize_fields('stripe', [ diff --git a/addons/payment_stripe/tests/common.py b/addons/payment_stripe/tests/common.py index 4cfdb71d192..5c5e75a828a 100644 --- a/addons/payment_stripe/tests/common.py +++ b/addons/payment_stripe/tests/common.py @@ -6,8 +6,8 @@ from odoo.addons.payment.tests.common import PaymentCommon class StripeCommon(PaymentCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.stripe = cls._prepare_acquirer('stripe', update_values={ 'stripe_secret_key': 'sk_test_KJtHgNwt2KS3xM7QJPr4O5E8',