From f7b8f07501315233c8208e99b311935815039a3a Mon Sep 17 00:00:00 2001 From: Horacio Tellez Date: Wed, 17 Aug 2022 08:23:30 +0000 Subject: [PATCH] [IMP] payment: rename of acquirer to provider Changing the name of model payment.acquirer to payment.provider and everything that it touches. It is technically incorrect to use the term "acquirer" for systems that only provide a service of payment. After this commit the model payment.acquirer and all related to it will be renamed to payment.provider. Task - 2842088 closes odoo/odoo#90899 Related: odoo/upgrade#3542 Related: odoo/documentation#1981 Related: odoo/enterprise#27131 Signed-off-by: Victor Feyens (vfe) --- addons/account/models/account_journal.py | 4 +- addons/account/models/account_payment.py | 2 +- .../account/models/account_payment_method.py | 2 +- addons/account/models/company.py | 2 +- .../wizard/account_payment_register.py | 2 +- addons/account_payment/__init__.py | 10 +- addons/account_payment/__manifest__.py | 2 +- addons/account_payment/controllers/portal.py | 18 +- addons/account_payment/models/__init__.py | 2 +- .../account_payment/models/account_journal.py | 38 ++-- addons/account_payment/models/account_move.py | 4 +- .../account_payment/models/account_payment.py | 24 +- .../models/account_payment_method.py | 6 +- .../models/account_payment_method_line.py | 38 ++-- ...ayment_acquirer.py => payment_provider.py} | 64 +++--- .../models/payment_transaction.py | 14 +- .../static/src/js/payment_form.js | 4 +- addons/account_payment/tests/common.py | 30 +-- .../tests/test_account_payment.py | 16 +- .../tests/test_payment_flows.py | 2 +- .../views/account_journal_views.xml | 10 +- .../views/account_payment_menus.xml | 4 +- .../views/account_portal_templates.xml | 6 +- ...r_views.xml => payment_provider_views.xml} | 10 +- .../wizards/account_payment_register.py | 16 +- .../wizards/payment_refund_wizard.py | 2 +- .../wizards/payment_refund_wizard_views.xml | 2 +- .../demo/website_demo.xml | 4 +- addons/payment/__init__.py | 8 +- addons/payment/__manifest__.py | 12 +- addons/payment/controllers/portal.py | 82 +++---- addons/payment/controllers/post_processing.py | 6 +- ...rer_data.xml => payment_provider_data.xml} | 30 +-- addons/payment/models/__init__.py | 2 +- addons/payment/models/ir_ui_view.py | 8 +- addons/payment/models/payment_icon.py | 6 +- ...ayment_acquirer.py => payment_provider.py} | 144 ++++++------ addons/payment/models/payment_token.py | 34 +-- addons/payment/models/payment_transaction.py | 210 +++++++++--------- addons/payment/models/res_company.py | 30 +-- addons/payment/security/ir.model.access.csv | 4 +- addons/payment/security/payment_security.xml | 8 +- addons/payment/static/src/js/checkout_form.js | 2 +- .../static/src/js/express_checkout_form.js | 22 +- .../static/src/js/payment_form_mixin.js | 68 +++--- ...nt_acquirer.scss => payment_provider.scss} | 2 +- .../src/xml/payment_post_processing.xml | 8 +- addons/payment/tests/__init__.py | 2 +- addons/payment/tests/common.py | 58 ++--- addons/payment/tests/http_common.py | 14 +- addons/payment/tests/test_flows.py | 60 ++--- .../payment/tests/test_multicompany_flows.py | 18 +- addons/payment/tests/test_payment_acquirer.py | 69 ------ addons/payment/tests/test_payment_provider.py | 69 ++++++ .../payment/tests/test_payment_transaction.py | 4 +- addons/payment/views/payment_icon_views.xml | 4 +- .../views/payment_portal_templates.xml | 14 +- ...r_views.xml => payment_provider_views.xml} | 68 +++--- addons/payment/views/payment_templates.xml | 138 ++++++------ addons/payment/views/payment_token_views.xml | 10 +- .../views/payment_transaction_views.xml | 14 +- addons/payment/wizards/payment_link_wizard.py | 58 ++--- .../wizards/payment_link_wizard_views.xml | 10 +- .../wizards/payment_onboarding_views.xml | 10 +- .../wizards/payment_onboarding_wizard.py | 76 +++---- addons/payment_adyen/__init__.py | 4 +- addons/payment_adyen/__manifest__.py | 10 +- addons/payment_adyen/controllers/main.py | 62 +++--- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_adyen/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 14 +- .../models/payment_transaction.py | 88 ++++---- .../static/src/js/payment_form.js | 34 +-- addons/payment_adyen/tests/common.py | 12 +- addons/payment_adyen/tests/test_adyen.py | 48 ++-- .../views/payment_adyen_templates.xml | 2 +- addons/payment_adyen/views/payment_views.xml | 34 +-- addons/payment_alipay/__init__.py | 6 +- addons/payment_alipay/__manifest__.py | 6 +- addons/payment_alipay/controllers/main.py | 6 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_alipay/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 20 +- .../models/payment_transaction.py | 30 +-- addons/payment_alipay/tests/common.py | 4 +- addons/payment_alipay/tests/test_alipay.py | 34 +-- addons/payment_alipay/views/payment_views.xml | 16 +- addons/payment_aps/__init__.py | 4 +- addons/payment_aps/__manifest__.py | 6 +- addons/payment_aps/controllers/main.py | 2 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_aps/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 8 +- .../payment_aps/models/payment_transaction.py | 36 +-- addons/payment_aps/tests/__init__.py | 2 +- addons/payment_aps/tests/common.py | 8 +- .../tests/test_payment_acquirer.py | 16 -- .../tests/test_payment_provider.py | 16 ++ .../tests/test_payment_transaction.py | 6 +- addons/payment_aps/views/payment_views.xml | 20 +- addons/payment_asiapay/__init__.py | 4 +- addons/payment_asiapay/__manifest__.py | 6 +- addons/payment_asiapay/controllers/main.py | 2 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_asiapay/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 20 +- .../models/payment_transaction.py | 40 ++-- addons/payment_asiapay/tests/__init__.py | 2 +- addons/payment_asiapay/tests/common.py | 4 +- ...t_acquirer.py => test_payment_provider.py} | 20 +- .../tests/test_payment_transaction.py | 14 +- .../payment_asiapay/views/payment_views.xml | 20 +- addons/payment_authorize/__init__.py | 4 +- addons/payment_authorize/__manifest__.py | 10 +- addons/payment_authorize/controllers/main.py | 20 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_authorize/models/__init__.py | 2 +- .../models/authorize_request.py | 20 +- ...ayment_acquirer.py => payment_provider.py} | 36 +-- .../payment_authorize/models/payment_token.py | 1 - .../models/payment_transaction.py | 62 +++--- .../static/src/js/payment_form.js | 62 +++--- addons/payment_authorize/tests/common.py | 4 +- .../payment_authorize/tests/test_authorize.py | 22 +- .../views/payment_authorize_templates.xml | 38 ++-- .../payment_authorize/views/payment_views.xml | 36 +-- addons/payment_buckaroo/__init__.py | 4 +- addons/payment_buckaroo/__manifest__.py | 10 +- addons/payment_buckaroo/controllers/main.py | 2 +- .../data/payment_provider_data.xml} | 4 +- addons/payment_buckaroo/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 6 +- .../models/payment_transaction.py | 26 +-- addons/payment_buckaroo/tests/common.py | 4 +- .../payment_buckaroo/tests/test_buckaroo.py | 12 +- .../payment_buckaroo/views/payment_views.xml | 18 +- addons/payment_custom/__init__.py | 4 +- addons/payment_custom/__manifest__.py | 6 +- ...rer_data.xml => payment_provider_data.xml} | 8 +- addons/payment_custom/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 26 +-- .../models/payment_transaction.py | 26 +-- .../static/src/js/post_processing.js | 2 +- .../views/payment_custom_templates.xml | 4 +- addons/payment_custom/views/payment_views.xml | 12 +- addons/payment_demo/__init__.py | 4 +- addons/payment_demo/__manifest__.py | 6 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_demo/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 20 +- addons/payment_demo/models/payment_token.py | 2 +- .../models/payment_transaction.py | 34 +-- .../static/src/js/payment_form.js | 14 +- addons/payment_demo/tests/common.py | 2 +- .../tests/test_payment_transaction.py | 2 +- .../views/payment_demo_templates.xml | 4 +- .../payment_demo/views/payment_templates.xml | 2 +- .../views/payment_token_views.xml | 4 +- .../views/payment_transaction_views.xml | 8 +- addons/payment_flutterwave/__init__.py | 4 +- addons/payment_flutterwave/__manifest__.py | 6 +- .../payment_flutterwave/controllers/main.py | 2 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_flutterwave/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 18 +- .../models/payment_transaction.py | 34 +-- addons/payment_flutterwave/tests/__init__.py | 2 +- addons/payment_flutterwave/tests/common.py | 4 +- ...t_acquirer.py => test_payment_provider.py} | 18 +- .../tests/test_payment_transaction.py | 6 +- .../tests/test_processing_flows.py | 2 +- .../views/payment_views.xml | 18 +- addons/payment_mercado_pago/__init__.py | 4 +- addons/payment_mercado_pago/__manifest__.py | 6 +- .../data/payment_acquirer_data.xml | 9 - .../data/payment_provider_data.xml} | 4 +- .../payment_mercado_pago/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 16 +- .../models/payment_transaction.py | 28 +-- addons/payment_mercado_pago/tests/__init__.py | 2 +- addons/payment_mercado_pago/tests/common.py | 2 +- ...t_acquirer.py => test_payment_provider.py} | 14 +- .../tests/test_payment_transaction.py | 2 +- .../views/payment_views.xml | 14 +- addons/payment_mollie/__init__.py | 4 +- addons/payment_mollie/__manifest__.py | 11 +- .../data/payment_provider_data.xml} | 4 +- addons/payment_mollie/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 18 +- .../models/payment_transaction.py | 28 +-- addons/payment_mollie/tests/common.py | 4 +- addons/payment_mollie/tests/test_mollie.py | 2 +- addons/payment_mollie/views/payment_views.xml | 16 +- addons/payment_ogone/__init__.py | 6 +- addons/payment_ogone/__manifest__.py | 6 +- addons/payment_ogone/controllers/main.py | 2 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_ogone/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 20 +- .../models/payment_transaction.py | 58 ++--- addons/payment_ogone/tests/common.py | 4 +- addons/payment_ogone/tests/test_ogone.py | 22 +- addons/payment_ogone/views/payment_views.xml | 26 +-- addons/payment_paypal/__init__.py | 4 +- addons/payment_paypal/__manifest__.py | 10 +- addons/payment_paypal/controllers/main.py | 8 +- .../data/payment_paypal_email_data.xml | 2 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_paypal/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 22 +- .../models/payment_transaction.py | 30 +-- addons/payment_paypal/tests/common.py | 4 +- addons/payment_paypal/tests/test_paypal.py | 10 +- addons/payment_paypal/views/payment_views.xml | 24 +- addons/payment_payulatam/__init__.py | 6 +- addons/payment_payulatam/__manifest__.py | 6 +- addons/payment_payulatam/controllers/main.py | 2 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_payulatam/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 16 +- .../models/payment_transaction.py | 40 ++-- addons/payment_payulatam/tests/common.py | 4 +- .../payment_payulatam/tests/test_payulatam.py | 32 +-- .../payment_payulatam/views/payment_views.xml | 20 +- addons/payment_payumoney/__init__.py | 6 +- addons/payment_payumoney/__manifest__.py | 6 +- addons/payment_payumoney/controllers/main.py | 2 +- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_payumoney/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 16 +- .../models/payment_transaction.py | 24 +- addons/payment_payumoney/tests/common.py | 4 +- .../payment_payumoney/tests/test_payumoney.py | 16 +- .../payment_payumoney/views/payment_views.xml | 18 +- addons/payment_razorpay/__init__.py | 4 +- addons/payment_razorpay/__manifest__.py | 6 +- addons/payment_razorpay/controllers/main.py | 2 +- .../data/payment_acquirer_data.xml | 9 - .../data/payment_provider_data.xml | 9 + addons/payment_razorpay/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 18 +- .../models/payment_transaction.py | 56 ++--- addons/payment_razorpay/tests/__init__.py | 2 +- addons/payment_razorpay/tests/common.py | 2 +- ...t_acquirer.py => test_payment_provider.py} | 20 +- .../tests/test_payment_transaction.py | 4 +- .../tests/test_processing_flows.py | 4 +- .../payment_razorpay/views/payment_views.xml | 18 +- addons/payment_sips/__init__.py | 4 +- addons/payment_sips/__manifest__.py | 8 +- addons/payment_sips/controllers/main.py | 2 +- .../data/payment_provider_data.xml | 9 + addons/payment_sips/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 16 +- .../models/payment_transaction.py | 38 ++-- addons/payment_sips/tests/common.py | 4 +- addons/payment_sips/tests/test_sips.py | 20 +- addons/payment_sips/views/payment_views.xml | 26 +-- addons/payment_stripe/__init__.py | 4 +- addons/payment_stripe/__manifest__.py | 10 +- addons/payment_stripe/controllers/main.py | 12 +- .../payment_stripe/controllers/onboarding.py | 26 +-- ...rer_data.xml => payment_provider_data.xml} | 4 +- addons/payment_stripe/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 32 +-- addons/payment_stripe/models/payment_token.py | 4 +- .../models/payment_transaction.py | 70 +++--- .../static/src/js/express_checkout_form.js | 22 +- .../static/src/js/payment_form.js | 6 +- addons/payment_stripe/tests/common.py | 4 +- .../payment_stripe/tests/test_refund_flows.py | 10 +- addons/payment_stripe/tests/test_stripe.py | 30 +-- addons/payment_stripe/utils.py | 24 +- .../views/payment_stripe_templates.xml | 10 +- addons/payment_stripe/views/payment_views.xml | 28 +-- .../pos_stripe/models/pos_payment_method.py | 6 +- addons/sale/controllers/portal.py | 18 +- addons/sale/data/mail_template_data.xml | 2 +- addons/sale/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 4 +- addons/sale/models/payment_transaction.py | 14 +- addons/sale/models/res_company.py | 6 +- addons/sale/models/res_config_settings.py | 4 +- addons/sale/models/sale_order.py | 6 +- addons/sale/security/ir.model.access.csv | 2 +- addons/sale/security/ir_rules.xml | 6 +- addons/sale/static/src/js/payment_form.js | 4 +- addons/sale/static/src/js/tours/sale.js | 2 +- addons/sale/tests/test_payment_flow.py | 8 +- addons/sale/views/payment_views.xml | 10 +- .../sale/views/res_config_settings_views.xml | 2 +- addons/sale/views/sale_onboarding_views.xml | 10 +- addons/sale/views/sale_portal_templates.xml | 2 +- addons/sale/wizard/__init__.py | 2 +- addons/sale/wizard/payment_link_wizard.py | 10 +- ... => payment_provider_onboarding_wizard.py} | 8 +- .../src/js/tours/wevent_performance_tour.js | 2 +- .../test_event_full/tests/test_performance.py | 2 +- .../tests/test_ui_wslides.py | 2 +- .../tours/slides_certification_member.js | 2 +- .../web/static/src/legacy/scss/form_view.scss | 2 +- .../src/views/form/form_controller.scss | 2 +- .../tests/test_wevent_booth_exhibitor.py | 8 +- .../tests/test_frontend_buy_tickets.py | 28 +-- addons/website_payment/__manifest__.py | 4 +- addons/website_payment/controllers/portal.py | 16 +- .../website_payment/data/ir_action_data.xml | 4 +- .../website_payment/data/mail_templates.xml | 2 +- addons/website_payment/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 4 +- .../models/res_config_settings.py | 42 ++-- .../static/src/js/website_payment_form.js | 30 +-- .../views/donation_templates.xml | 6 +- ...ment_acquirer.xml => payment_provider.xml} | 8 +- .../views/res_config_settings_views.xml | 10 +- .../website_payment_authorize/__manifest__.py | 2 +- .../models/res_config_settings.py | 4 +- addons/website_payment_paypal/__manifest__.py | 2 +- .../models/res_config_settings.py | 4 +- addons/website_sale/controllers/main.py | 40 ++-- addons/website_sale/models/__init__.py | 2 +- .../website_sale/models/payment_acquirer.py | 26 --- .../website_sale/models/payment_provider.py | 25 +++ addons/website_sale/models/res_company.py | 4 +- .../static/src/js/website_sale_tracking.js | 2 +- .../website_sale/tests/test_sale_process.py | 20 +- .../tests/test_website_sale_cart_abandoned.py | 2 +- .../website_sale/views/sale_order_views.xml | 6 +- addons/website_sale/views/templates.xml | 22 +- addons/website_sale_delivery/tests/test_ui.py | 6 +- .../website_sale_picking/controllers/main.py | 4 +- .../data/website_sale_picking_data.xml | 4 +- .../website_sale_picking/models/__init__.py | 2 +- ...ayment_acquirer.py => payment_provider.py} | 23 +- .../static/tests/tours/onsite_payment_tour.js | 4 +- .../website_sale_picking/views/templates.xml | 4 +- odoo/addons/base/data/ir_module_module.xml | 2 +- 337 files changed, 2476 insertions(+), 2470 deletions(-) rename addons/account_payment/models/{payment_acquirer.py => payment_provider.py} (57%) rename addons/account_payment/views/{payment_acquirer_views.xml => payment_provider_views.xml} (65%) rename addons/payment/data/{payment_acquirer_data.xml => payment_provider_data.xml} (92%) rename addons/payment/models/{payment_acquirer.py => payment_provider.py} (83%) rename addons/payment/static/src/scss/{payment_acquirer.scss => payment_provider.scss} (91%) delete mode 100644 addons/payment/tests/test_payment_acquirer.py create mode 100644 addons/payment/tests/test_payment_provider.py rename addons/payment/views/{payment_acquirer_views.xml => payment_provider_views.xml} (85%) rename addons/payment_adyen/data/{payment_acquirer_data.xml => payment_provider_data.xml} (62%) rename addons/payment_adyen/models/{payment_acquirer.py => payment_provider.py} (95%) rename addons/payment_alipay/data/{payment_acquirer_data.xml => payment_provider_data.xml} (89%) rename addons/payment_alipay/models/{payment_acquirer.py => payment_provider.py} (82%) rename addons/payment_aps/data/{payment_acquirer_data.xml => payment_provider_data.xml} (56%) rename addons/payment_aps/models/{payment_acquirer.py => payment_provider.py} (95%) delete mode 100644 addons/payment_aps/tests/test_payment_acquirer.py create mode 100644 addons/payment_aps/tests/test_payment_provider.py rename addons/payment_asiapay/data/{payment_acquirer_data.xml => payment_provider_data.xml} (54%) rename addons/payment_asiapay/models/{payment_acquirer.py => payment_provider.py} (85%) rename addons/payment_asiapay/tests/{test_payment_acquirer.py => test_payment_provider.py} (70%) rename addons/payment_authorize/data/{payment_acquirer_data.xml => payment_provider_data.xml} (61%) rename addons/payment_authorize/models/{payment_acquirer.py => payment_provider.py} (84%) rename addons/{payment_mollie/data/payment_acquirer_data.xml => payment_buckaroo/data/payment_provider_data.xml} (55%) mode change 100755 => 100644 rename addons/payment_buckaroo/models/{payment_acquirer.py => payment_provider.py} (96%) rename addons/payment_custom/data/{payment_acquirer_data.xml => payment_provider_data.xml} (63%) rename addons/payment_custom/models/{payment_acquirer.py => payment_provider.py} (74%) rename addons/payment_demo/data/{payment_acquirer_data.xml => payment_provider_data.xml} (70%) rename addons/payment_demo/models/{payment_acquirer.py => payment_provider.py} (56%) rename addons/payment_flutterwave/data/{payment_acquirer_data.xml => payment_provider_data.xml} (60%) rename addons/payment_flutterwave/models/{payment_acquirer.py => payment_provider.py} (88%) rename addons/payment_flutterwave/tests/{test_payment_acquirer.py => test_payment_provider.py} (50%) delete mode 100644 addons/payment_mercado_pago/data/payment_acquirer_data.xml rename addons/{payment_buckaroo/data/payment_acquirer_data.xml => payment_mercado_pago/data/payment_provider_data.xml} (53%) rename addons/payment_mercado_pago/models/{payment_acquirer.py => payment_provider.py} (88%) rename addons/payment_mercado_pago/tests/{test_payment_acquirer.py => test_payment_provider.py} (51%) rename addons/{payment_sips/data/payment_acquirer_data.xml => payment_mollie/data/payment_provider_data.xml} (56%) mode change 100644 => 100755 rename addons/payment_mollie/models/{payment_acquirer.py => payment_provider.py} (85%) rename addons/payment_ogone/data/{payment_acquirer_data.xml => payment_provider_data.xml} (89%) rename addons/payment_ogone/models/{payment_acquirer.py => payment_provider.py} (91%) rename addons/payment_paypal/data/{payment_acquirer_data.xml => payment_provider_data.xml} (55%) rename addons/payment_paypal/models/{payment_acquirer.py => payment_provider.py} (82%) rename addons/payment_payulatam/data/{payment_acquirer_data.xml => payment_provider_data.xml} (88%) rename addons/payment_payulatam/models/{payment_acquirer.py => payment_provider.py} (87%) rename addons/payment_payumoney/data/{payment_acquirer_data.xml => payment_provider_data.xml} (89%) rename addons/payment_payumoney/models/{payment_acquirer.py => payment_provider.py} (83%) delete mode 100644 addons/payment_razorpay/data/payment_acquirer_data.xml create mode 100644 addons/payment_razorpay/data/payment_provider_data.xml rename addons/payment_razorpay/models/{payment_acquirer.py => payment_provider.py} (90%) rename addons/payment_razorpay/tests/{test_payment_acquirer.py => test_payment_provider.py} (57%) create mode 100644 addons/payment_sips/data/payment_provider_data.xml rename addons/payment_sips/models/{payment_acquirer.py => payment_provider.py} (83%) rename addons/payment_stripe/data/{payment_acquirer_data.xml => payment_provider_data.xml} (69%) rename addons/payment_stripe/models/{payment_acquirer.py => payment_provider.py} (94%) rename addons/sale/models/{payment_acquirer.py => payment_provider.py} (88%) rename addons/sale/wizard/{payment_acquirer_onboarding_wizard.py => payment_provider_onboarding_wizard.py} (86%) rename addons/website_payment/models/{payment_acquirer.py => payment_provider.py} (87%) rename addons/website_payment/views/{payment_acquirer.xml => payment_provider.xml} (61%) delete mode 100644 addons/website_sale/models/payment_acquirer.py create mode 100644 addons/website_sale/models/payment_provider.py rename addons/website_sale_picking/models/{payment_acquirer.py => payment_provider.py} (66%) diff --git a/addons/account/models/account_journal.py b/addons/account/models/account_journal.py index ed53255b2c1..12b8e52db44 100644 --- a/addons/account/models/account_journal.py +++ b/addons/account/models/account_journal.py @@ -126,7 +126,7 @@ class AccountJournal(models.Model): copy=False, check_company=True, help="Manual: Get paid by any method outside of Odoo.\n" - "Payment Acquirers: Each payment acquirer has its own Payment Method. Request a transaction on/to a card thanks to a payment token saved by the partner when buying or subscribing online.\n" + "Payment Providers: Each payment provider has its own Payment Method. Request a transaction on/to a card thanks to a payment token saved by the partner when buying or subscribing online.\n" "Batch Deposit: Collect several customer checks at once generating and submitting a batch deposit to your bank. Module account_batch_payment is necessary.\n" "SEPA Direct Debit: Get paid in the SEPA zone thanks to a mandate your partner will have granted to you. Module account_sepa is necessary.\n" ) @@ -901,7 +901,7 @@ class AccountJournal(models.Model): This getter is here to allow filtering the payment method lines if needed in other modules. It does NOT serve as a general getter to get the lines. - For example, it'll be extended to filter out lines from inactive payment acquirers in the payment module. + For example, it'll be extended to filter out lines from inactive payment providers in the payment module. :param payment_type: either inbound or outbound, used to know which lines to return :return: Either the inbound or outbound payment method lines """ diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 12c376990e3..764d16a60b4 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -47,7 +47,7 @@ class AccountPayment(models.Model): compute='_compute_payment_method_line_id', domain="[('id', 'in', available_payment_method_line_ids)]", help="Manual: Pay or Get paid by any method outside of Odoo.\n" - "Payment Acquirers: Each payment acquirer has its own Payment Method. Request a transaction on/to a card thanks to a payment token saved by the partner when buying or subscribing online.\n" + "Payment Providers: Each payment provider has its own Payment Method. Request a transaction on/to a card thanks to a payment token saved by the partner when buying or subscribing online.\n" "Check: Pay bills by check and print it from Odoo.\n" "Batch Deposit: Collect several customer checks at once generating and submitting a batch deposit to your bank. Module account_batch_payment is necessary.\n" "SEPA Credit Transfer: Pay in the SEPA zone by submitting a SEPA Credit Transfer file to your bank. Module account_sepa is necessary.\n" diff --git a/addons/account/models/account_payment_method.py b/addons/account/models/account_payment_method.py index 16577338b80..1f7bde0b5f7 100644 --- a/addons/account/models/account_payment_method.py +++ b/addons/account/models/account_payment_method.py @@ -67,7 +67,7 @@ class AccountPaymentMethod(models.Model): """ Contains details about how to initialize a payment method with the code x. The contained info are: - mode: Either unique if we only want one of them at a single time (payment acquirers for example) + mode: Either unique if we only want one of them at a single time (payment providers for example) or multi if we want the method on each journal fitting the domain. domain: The domain defining the eligible journals. currency_id: The id of the currency necessary on the journal (or company) for it to be eligible. diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 61bdb338293..1cf17d753db 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -224,7 +224,7 @@ class ResCompany(models.Model): # YTI FIXME: Define only one method that returns {'account': [], 'sale': [], ...} def get_account_invoice_onboarding_steps_states_names(self): - """ Necessary to add/edit steps from other modules (payment acquirer in this case). """ + """ Necessary to add/edit steps from other modules (payment provider in this case). """ return [ 'base_onboarding_company_state', 'account_onboarding_invoice_layout_state', diff --git a/addons/account/wizard/account_payment_register.py b/addons/account/wizard/account_payment_register.py index 162264ad9e5..934f414fbb9 100644 --- a/addons/account/wizard/account_payment_register.py +++ b/addons/account/wizard/account_payment_register.py @@ -88,7 +88,7 @@ class AccountPaymentRegister(models.TransientModel): compute='_compute_payment_method_line_id', domain="[('id', 'in', available_payment_method_line_ids)]", help="Manual: Pay or Get paid by any method outside of Odoo.\n" - "Payment Acquirers: Each payment acquirer has its own Payment Method. Request a transaction on/to a card thanks to a payment token saved by the partner when buying or subscribing online.\n" + "Payment Providers: Each payment provider has its own Payment Method. Request a transaction on/to a card thanks to a payment token saved by the partner when buying or subscribing online.\n" "Check: Pay bills by check and print it from Odoo.\n" "Batch Deposit: Collect several customer checks at once generating and submitting a batch deposit to your bank. Module account_batch_payment is necessary.\n" "SEPA Credit Transfer: Pay in the SEPA zone by submitting a SEPA Credit Transfer file to your bank. Module account_sepa is necessary.\n" diff --git a/addons/account_payment/__init__.py b/addons/account_payment/__init__.py index c722f591c88..c8b4631d454 100644 --- a/addons/account_payment/__init__.py +++ b/addons/account_payment/__init__.py @@ -10,16 +10,16 @@ from odoo import api, SUPERUSER_ID def post_init_hook(cr, registry): """ Create `account.payment.method` records for the installed payment providers. """ env = api.Environment(cr, SUPERUSER_ID, {}) - PaymentAcquirer = env['payment.acquirer'] - installed_providers = PaymentAcquirer.search([('module_id.state', '=', 'installed')]) - for provider_code in set(installed_providers.mapped('provider')): - PaymentAcquirer._setup_payment_method(provider_code) + PaymentProvider = env['payment.provider'] + installed_providers = PaymentProvider.search([('module_id.state', '=', 'installed')]) + for code in set(installed_providers.mapped('code')): + PaymentProvider._setup_payment_method(code) def uninstall_hook(cr, registry): """ Delete `account.payment.method` records created for the installed payment providers. """ env = api.Environment(cr, SUPERUSER_ID, {}) - installed_providers = env['payment.acquirer'].search([('module_id.state', '=', 'installed')]) + installed_providers = env['payment.provider'].search([('module_id.state', '=', 'installed')]) env['account.payment.method'].search([ ('code', 'in', installed_providers.mapped('provider')), ('payment_type', '=', 'inbound'), diff --git a/addons/account_payment/__manifest__.py b/addons/account_payment/__manifest__.py index 91f8825b3b0..ddd1d153e14 100644 --- a/addons/account_payment/__manifest__.py +++ b/addons/account_payment/__manifest__.py @@ -17,7 +17,7 @@ 'views/account_move_views.xml', 'views/account_journal_views.xml', 'views/account_payment_views.xml', - 'views/payment_acquirer_views.xml', + 'views/payment_provider_views.xml', 'views/payment_transaction_views.xml', 'wizards/account_payment_register_views.xml', diff --git a/addons/account_payment/controllers/portal.py b/addons/account_payment/controllers/portal.py index 9cb61da274d..e0d6876ae04 100644 --- a/addons/account_payment/controllers/portal.py +++ b/addons/account_payment/controllers/portal.py @@ -22,23 +22,23 @@ class PortalAccount(portal.PortalAccount): invoice_company = invoice.company_id or request.env.company PaymentPortal._ensure_matching_companies(partner, invoice_company) - acquirers_sudo = request.env['payment.acquirer'].sudo()._get_compatible_acquirers( + providers_sudo = request.env['payment.provider'].sudo()._get_compatible_providers( invoice_company.id, partner.id, invoice.amount_total, currency_id=invoice.currency_id.id - ) # In sudo mode to read the fields of acquirers and partner (if not logged in) + ) # In sudo mode to read the fields of providers and partner (if not logged in) tokens = request.env['payment.token'].search( - [('acquirer_id', 'in', acquirers_sudo.ids), ('partner_id', '=', partner.id)] + [('provider_id', 'in', providers_sudo.ids), ('partner_id', '=', partner.id)] ) # Tokens are cleared at the end if the user is not logged in - fees_by_acquirer = { - acq_sudo: acq_sudo._compute_fees( + fees_by_provider = { + pro_sudo: pro_sudo._compute_fees( invoice.amount_total, invoice.currency_id, invoice.partner_id.country_id - ) for acq_sudo in acquirers_sudo.filtered('fees_active') + ) for pro_sudo in providers_sudo.filtered('fees_active') } values.update({ - 'acquirers': acquirers_sudo, + 'providers': providers_sudo, 'tokens': tokens, - 'fees_by_acquirer': fees_by_acquirer, + 'fees_by_provider': fees_by_provider, 'show_tokenize_input': PaymentPortal._compute_show_tokenize_input_mapping( - acquirers_sudo, logged_in=logged_in + providers_sudo, logged_in=logged_in ), 'amount': invoice.amount_residual, 'currency': invoice.currency_id, diff --git a/addons/account_payment/models/__init__.py b/addons/account_payment/models/__init__.py index 034d2f7c8b0..1a548501a06 100644 --- a/addons/account_payment/models/__init__.py +++ b/addons/account_payment/models/__init__.py @@ -5,5 +5,5 @@ from . import account_move from . import account_payment from . import account_payment_method from . import account_payment_method_line -from . import payment_acquirer +from . import payment_provider from . import payment_transaction diff --git a/addons/account_payment/models/account_journal.py b/addons/account_payment/models/account_journal.py index e9ebcbf8e81..ed56e2ed200 100644 --- a/addons/account_payment/models/account_journal.py +++ b/addons/account_payment/models/account_journal.py @@ -11,50 +11,52 @@ class AccountJournal(models.Model): @api.constrains('inbound_payment_method_line_ids') def _check_inbound_payment_method_line_ids(self): """ - Check and ensure that the user do not remove a apml that is linked to an acquirer in the test or enabled state. + Check and ensure that the user do not remove a apml that is linked to a provider in the test or enabled state. """ if not self.company_id: return self.env['account.payment.method'].flush_model(['code', 'payment_type']) self.env['account.payment.method.line'].flush_model(['payment_method_id']) - self.env['payment.acquirer'].flush_model(['provider', 'state']) + self.env['payment.provider'].flush_model(['code', 'state']) self._cr.execute(''' - SELECT acquirer.id - FROM payment_acquirer acquirer + SELECT provider.id + FROM payment_provider provider JOIN account_payment_method apm - ON apm.code = acquirer.provider + ON apm.code = provider.code LEFT JOIN account_payment_method_line apml ON apm.id = apml.payment_method_id AND apml.journal_id IS NOT NULL - WHERE acquirer.state IN ('enabled', 'test') - AND acquirer.provider != 'custom' + WHERE provider.state IN ('enabled', 'test') + AND provider.code != 'custom' AND apm.payment_type = 'inbound' AND apml.id IS NULL - AND acquirer.company_id IN %(company_ids)s + AND provider.company_id IN %(company_ids)s ''', {'company_ids': tuple(self.company_id.ids)}) ids = [r[0] for r in self._cr.fetchall()] if ids: - acquirers = self.env['payment.acquirer'].sudo().browse(ids) - raise UserError(_("You can't delete a payment method that is linked to an acquirer in the enabled or test state.\n" - "Linked acquirer(s): %s", ', '.join(a.display_name for a in acquirers))) + providers = self.env['payment.provider'].sudo().browse(ids) + raise UserError( + _("You can't delete a payment method that is linked to a provider in the enabled or test state.\n" + "Linked provider(s): %s", ', '.join(p.display_name for p in providers)) + ) def _get_available_payment_method_lines(self, payment_type): lines = super()._get_available_payment_method_lines(payment_type) - return lines.filtered(lambda l: l.payment_acquirer_state != 'disabled') + return lines.filtered(lambda l: l.payment_provider_state != 'disabled') @api.depends('outbound_payment_method_line_ids', 'inbound_payment_method_line_ids') def _compute_available_payment_method_ids(self): super()._compute_available_payment_method_ids() - installed_acquirers = self.env['payment.acquirer'].sudo().search([]) + installed_providers = self.env['payment.provider'].sudo().search([]) method_information = self.env['account.payment.method']._get_payment_method_information() pay_methods = self.env['account.payment.method'].search([('code', 'in', list(method_information.keys()))]) pay_method_by_code = {x.code + x.payment_type: x for x in pay_methods} - # On top of the basic filtering, filter to hide unavailable acquirers. - # This avoid allowing payment method lines linked to an acquirer that has no record. + # On top of the basic filtering, filter to hide unavailable providers. + # This avoid allowing payment method lines linked to a provider that has no record. for code, vals in method_information.items(): payment_method = pay_method_by_code.get(code + 'inbound') @@ -64,9 +66,9 @@ class AccountJournal(models.Model): for journal in self: to_remove = [] - available_providers = installed_acquirers.filtered( - lambda a: a.company_id == journal.company_id - ).mapped('provider') + available_providers = installed_providers.filtered( + lambda p: p.company_id == journal.company_id + ).mapped('code') available = payment_method.code in available_providers if vals['mode'] == 'unique' and not available: diff --git a/addons/account_payment/models/account_move.py b/addons/account_payment/models/account_move.py index e14454a47a3..bf4b8e82772 100644 --- a/addons/account_payment/models/account_move.py +++ b/addons/account_payment/models/account_move.py @@ -45,13 +45,13 @@ class AccountMove(models.Model): def payment_action_capture(self): """ Capture all transactions linked to this invoice. """ payment_utils.check_rights_on_recordset(self) - # In sudo mode because we need to be able to read on acquirer fields. + # In sudo mode because we need to be able to read on provider fields. self.authorized_transaction_ids.sudo().action_capture() def payment_action_void(self): """ Void all transactions linked to this invoice. """ payment_utils.check_rights_on_recordset(self) - # In sudo mode because we need to be able to read on acquirer fields. + # In sudo mode because we need to be able to read on provider fields. self.authorized_transaction_ids.sudo().action_void() def action_view_payment_transactions(self): diff --git a/addons/account_payment/models/account_payment.py b/addons/account_payment/models/account_payment.py index 1ffbce501ca..d20871cc52b 100644 --- a/addons/account_payment/models/account_payment.py +++ b/addons/account_payment/models/account_payment.py @@ -18,7 +18,7 @@ class AccountPayment(models.Model): string="Saved Payment Token", comodel_name='payment.token', domain="""[ ('id', 'in', suitable_payment_token_ids), ]""", - help="Note that only tokens from acquirers allowing to capture the amount are available.") + help="Note that only tokens from providers allowing to capture the amount are available.") amount_available_for_refund = fields.Monetary(compute='_compute_amount_available_for_refund') # == Display purpose fields == @@ -48,7 +48,7 @@ class AccountPayment(models.Model): def _compute_amount_available_for_refund(self): for payment in self: tx_sudo = payment.payment_transaction_id.sudo() - if tx_sudo.acquirer_id.support_refund and tx_sudo.operation != 'refund': + if tx_sudo.provider_id.support_refund and tx_sudo.operation != 'refund': # Only consider refund transactions that are confirmed by summing the amounts of # payments linked to such refund transactions. Indeed, should a refund transaction # be stuck forever in a transient state (due to webhook failure, for example), the @@ -71,9 +71,9 @@ class AccountPayment(models.Model): if payment.use_electronic_payment_method: payment.suitable_payment_token_ids = self.env['payment.token'].sudo().search([ ('company_id', '=', payment.company_id.id), - ('acquirer_id.capture_manually', '=', False), + ('provider_id.capture_manually', '=', False), ('partner_id', 'in', related_partner_ids.ids), - ('acquirer_id', '=', payment.payment_method_line_id.payment_acquirer_id.id), + ('provider_id', '=', payment.payment_method_line_id.payment_provider_id.id), ]) else: payment.suitable_payment_token_ids = [Command.clear()] @@ -82,8 +82,8 @@ class AccountPayment(models.Model): def _compute_use_electronic_payment_method(self): for payment in self: # Get a list of all electronic payment method codes. - # These codes are comprised of 'electronic' and the providers of each payment acquirer. - codes = [key for key in dict(self.env['payment.acquirer']._fields['provider']._description_selection(self.env))] + # These codes are comprised of 'electronic' and the providers of each payment provider. + codes = [key for key in dict(self.env['payment.provider']._fields['code']._description_selection(self.env))] payment.use_electronic_payment_method = payment.payment_method_code in codes def _compute_refunds_count(self): @@ -103,7 +103,7 @@ class AccountPayment(models.Model): @api.onchange('partner_id', 'payment_method_line_id', 'journal_id') def _onchange_set_payment_token_id(self): - codes = [key for key in dict(self.env['payment.acquirer']._fields['provider']._description_selection(self.env))] + codes = [key for key in dict(self.env['payment.provider']._fields['code']._description_selection(self.env))] if not (self.payment_method_code in codes and self.partner_id and self.journal_id): self.payment_token_id = False return @@ -117,20 +117,20 @@ class AccountPayment(models.Model): self.payment_token_id = self.env['payment.token'].sudo().search([ ('company_id', '=', self.company_id.id), ('partner_id', 'in', related_partner_ids.ids), - ('acquirer_id.capture_manually', '=', False), - ('acquirer_id', '=', self.payment_method_line_id.payment_acquirer_id.id), + ('provider_id.capture_manually', '=', False), + ('provider_id', '=', self.payment_method_line_id.payment_provider_id.id), ], limit=1) #=== ACTION METHODS ===# def action_post(self): # Post the payments "normally" if no transactions are needed. - # If not, let the acquirer update the state. + # If not, let the provider update the state. payments_need_tx = self.filtered( lambda p: p.payment_token_id and not p.payment_transaction_id ) - # creating the transaction require to access data on payment acquirers, not always accessible to users + # creating the transaction require to access data on payment providers, not always accessible to users # able to create payments transactions = payments_need_tx.sudo()._create_payment_transaction() @@ -203,7 +203,7 @@ class AccountPayment(models.Model): def _prepare_payment_transaction_vals(self, **extra_create_values): self.ensure_one() return { - 'acquirer_id': self.payment_token_id.acquirer_id.id, + 'provider_id': self.payment_token_id.provider_id.id, 'reference': self.ref, 'amount': self.amount, 'currency_id': self.currency_id.id, diff --git a/addons/account_payment/models/account_payment_method.py b/addons/account_payment/models/account_payment_method.py index b6f35aefe8a..a269cc95c60 100644 --- a/addons/account_payment/models/account_payment_method.py +++ b/addons/account_payment/models/account_payment_method.py @@ -10,10 +10,10 @@ class AccountPaymentMethod(models.Model): @api.model def _get_payment_method_information(self): res = super()._get_payment_method_information() - for provider, _desc in self.env['payment.acquirer']._fields['provider'].selection: - if provider in ('none', 'transfer'): + for code, _desc in self.env['payment.provider']._fields['code'].selection: + if code in ('none', 'transfer'): continue - res[provider] = { + res[code] = { 'mode': 'unique', 'domain': [('type', '=', 'bank')], } diff --git a/addons/account_payment/models/account_payment_method_line.py b/addons/account_payment/models/account_payment_method_line.py index 1f17edcafe9..b141bc10365 100644 --- a/addons/account_payment/models/account_payment_method_line.py +++ b/addons/account_payment/models/account_payment_method_line.py @@ -8,35 +8,35 @@ from odoo.osv import expression class AccountPaymentMethodLine(models.Model): _inherit = "account.payment.method.line" - payment_acquirer_id = fields.Many2one( - comodel_name='payment.acquirer', - compute='_compute_payment_acquirer_id', + payment_provider_id = fields.Many2one( + comodel_name='payment.provider', + compute='_compute_payment_provider_id', store=True ) - payment_acquirer_state = fields.Selection( - related='payment_acquirer_id.state' + payment_provider_state = fields.Selection( + related='payment_provider_id.state' ) @api.depends('payment_method_id') - def _compute_payment_acquirer_id(self): - acquirers = self.env['payment.acquirer'].sudo().search([ - ('provider', 'in', self.mapped('code')), + def _compute_payment_provider_id(self): + providers = self.env['payment.provider'].sudo().search([ + ('code', 'in', self.mapped('code')), ('company_id', 'in', self.journal_id.company_id.ids), ]) - # Make sure to pick the active acquirer, if any. - acquirers_map = dict() - for acquirer in acquirers: - current_value = acquirers_map.get((acquirer.provider, acquirer.company_id), False) + # Make sure to pick the active provider, if any. + providers_map = dict() + for provider in providers: + current_value = providers_map.get((provider.code, provider.company_id), False) if current_value and current_value.state != 'disabled': continue - acquirers_map[(acquirer.provider, acquirer.company_id)] = acquirer + providers_map[(provider.code, provider.company_id)] = provider for line in self: code = line.payment_method_id.code company = line.journal_id.company_id - line.payment_acquirer_id = acquirers_map.get((code, company), False) + line.payment_provider_id = providers_map.get((code, company), False) @api.model def _get_payment_method_domain(self, code): @@ -46,19 +46,19 @@ class AccountPaymentMethodLine(models.Model): unique = information.get('mode') == 'unique' if unique: - company_ids = self.env['payment.acquirer'].sudo().search([('provider', '=', code)]).mapped('company_id') + company_ids = self.env['payment.provider'].sudo().search([('code', '=', code)]).mapped('company_id') if company_ids: domain = expression.AND([domain, [('company_id', 'in', company_ids.ids)]]) return domain - def action_open_acquirer_form(self): + def action_open_provider_form(self): self.ensure_one() return { 'type': 'ir.actions.act_window', - 'name': _('Acquirer'), + 'name': _('Provider'), 'view_mode': 'form', - 'res_model': 'payment.acquirer', + 'res_model': 'payment.provider', 'target': 'current', - 'res_id': self.payment_acquirer_id.id + 'res_id': self.payment_provider_id.id } diff --git a/addons/account_payment/models/payment_acquirer.py b/addons/account_payment/models/payment_provider.py similarity index 57% rename from addons/account_payment/models/payment_acquirer.py rename to addons/account_payment/models/payment_provider.py index 11031b7545c..9416db46380 100644 --- a/addons/account_payment/models/payment_acquirer.py +++ b/addons/account_payment/models/payment_provider.py @@ -3,8 +3,8 @@ from odoo import api, fields, models -class PaymentAcquirer(models.Model): - _inherit = 'payment.acquirer' +class Paymentprovider(models.Model): + _inherit = 'payment.provider' journal_id = fields.Many2one( string="Payment Journal", @@ -17,74 +17,74 @@ class PaymentAcquirer(models.Model): #=== COMPUTE METHODS ===# - @api.depends('provider') + @api.depends('code') def _compute_journal_id(self): - for acquirer in self: + for provider in self: payment_method = self.env['account.payment.method.line'].search([ - ('journal_id.company_id', '=', acquirer.company_id.id), - ('code', '=', acquirer.provider) + ('journal_id.company_id', '=', provider.company_id.id), + ('code', '=', provider.code) ], limit=1) if payment_method: - acquirer.journal_id = payment_method.journal_id + provider.journal_id = payment_method.journal_id else: - acquirer.journal_id = False + provider.journal_id = False def _inverse_journal_id(self): - for acquirer in self: + for provider in self: payment_method_line = self.env['account.payment.method.line'].search([ - ('journal_id.company_id', '=', acquirer.company_id.id), - ('code', '=', acquirer.provider), + ('journal_id.company_id', '=', provider.company_id.id), + ('code', '=', provider.code), ], limit=1) - if acquirer.journal_id: + if provider.journal_id: if not payment_method_line: - default_payment_method_id = acquirer._get_default_payment_method_id( - acquirer.provider + default_payment_method_id = provider._get_default_payment_method_id( + provider.code ) existing_payment_method_line = self.env['account.payment.method.line'].search([ ('payment_method_id', '=', default_payment_method_id), - ('journal_id', '=', acquirer.journal_id.id), + ('journal_id', '=', provider.journal_id.id), ], limit=1) if not existing_payment_method_line: self.env['account.payment.method.line'].create({ 'payment_method_id': default_payment_method_id, - 'journal_id': acquirer.journal_id.id, + 'journal_id': provider.journal_id.id, }) else: - payment_method_line.journal_id = acquirer.journal_id + payment_method_line.journal_id = provider.journal_id elif payment_method_line: payment_method_line.unlink() @api.model - def _get_default_payment_method_id(self, provider): - provider_payment_method = self._get_provider_payment_method(provider) + def _get_default_payment_method_id(self, code): + provider_payment_method = self._get_provider_payment_method(code) if provider_payment_method: return provider_payment_method.id return self.env.ref('account.account_payment_method_manual_in').id @api.model - def _get_provider_payment_method(self, provider): - return self.env['account.payment.method'].search([('code', '=', provider)], limit=1) + def _get_provider_payment_method(self, code): + return self.env['account.payment.method'].search([('code', '=', code)], limit=1) #=== BUSINESS METHODS ===# @api.model - def _setup_provider(self, provider_code): + def _setup_provider(self, code): """ Override of `payment` to create the payment method of the provider. """ - super()._setup_provider(provider_code) - self._setup_payment_method(provider_code) + super()._setup_provider(code) + self._setup_payment_method(code) @api.model - def _setup_payment_method(self, provider): - if provider not in ('none', 'transfer') and not self._get_provider_payment_method(provider): - providers_description = dict(self._fields['provider']._description_selection(self.env)) + def _setup_payment_method(self, code): + if code not in ('none', 'transfer') and not self._get_provider_payment_method(code): + providers_description = dict(self._fields['code']._description_selection(self.env)) self.env['account.payment.method'].create({ - 'name': providers_description[provider], - 'code': provider, + 'name': providers_description[code], + 'code': code, 'payment_type': 'inbound', }) @api.model - def _remove_provider(self, provider): + def _remove_provider(self, code): """ Override of `payment` to delete the payment method of the provider. """ - super()._remove_provider(provider) - self._get_provider_payment_method(provider).unlink() + super()._remove_provider(code) + self._get_provider_payment_method(code).unlink() diff --git a/addons/account_payment/models/payment_transaction.py b/addons/account_payment/models/payment_transaction.py index e06d935b080..1018cb61e95 100644 --- a/addons/account_payment/models/payment_transaction.py +++ b/addons/account_payment/models/payment_transaction.py @@ -64,7 +64,7 @@ class PaymentTransaction(models.Model): #=== BUSINESS METHODS - PAYMENT FLOW ===# @api.model - def _compute_reference_prefix(self, provider, separator, **values): + def _compute_reference_prefix(self, provider_code, separator, **values): """ Compute the reference prefix from the transaction values. If the `values` parameter has an entry with 'invoice_ids' as key and a list of (4, id, O) or @@ -73,7 +73,7 @@ class PaymentTransaction(models.Model): Note: This method should be called in sudo mode to give access to documents (INV, SO, ...). - :param str provider: The provider of the acquirer handling the transaction + :param str provider_code: The code of the provider handling the transaction :param str separator: The custom separator used to separate data references :param dict values: The transaction values used to compute the reference prefix. It should have the structure {'invoice_ids': [(X2M command), ...], ...}. @@ -87,7 +87,7 @@ class PaymentTransaction(models.Model): invoices = self.env['account.move'].browse(invoice_ids).exists() if len(invoices) == len(invoice_ids): # All ids are valid return separator.join(invoices.mapped('name')) - return super()._compute_reference_prefix(provider, separator, **values) + return super()._compute_reference_prefix(provider_code, separator, **values) def _set_canceled(self, state_message=None): """ Update the transactions' state to 'cancel'. @@ -134,16 +134,16 @@ class PaymentTransaction(models.Model): """ self.ensure_one() - payment_method_line = self.acquirer_id.journal_id.inbound_payment_method_line_ids\ - .filtered(lambda l: l.code == self.provider) + payment_method_line = self.provider_id.journal_id.inbound_payment_method_line_ids\ + .filtered(lambda l: l.code == self.provider_code) payment_values = { 'amount': abs(self.amount), # A tx may have a negative amount, but a payment must >= 0 'payment_type': 'inbound' if self.amount > 0 else 'outbound', 'currency_id': self.currency_id.id, 'partner_id': self.partner_id.commercial_partner_id.id, 'partner_type': 'customer', - 'journal_id': self.acquirer_id.journal_id.id, - 'company_id': self.acquirer_id.company_id.id, + 'journal_id': self.provider_id.journal_id.id, + 'company_id': self.provider_id.company_id.id, 'payment_method_line_id': payment_method_line.id, 'payment_token_id': self.token_id.id, 'payment_transaction_id': self.id, diff --git a/addons/account_payment/static/src/js/payment_form.js b/addons/account_payment/static/src/js/payment_form.js index 1680562384b..9fb04c83439 100644 --- a/addons/account_payment/static/src/js/payment_form.js +++ b/addons/account_payment/static/src/js/payment_form.js @@ -15,12 +15,12 @@ odoo.define('account_payment.payment_form', require => { * * @override method from payment.payment_form_mixin * @private - * @param {string} provider - The provider of the selected payment option's acquirer. + * @param {string} code - The provider code of the selected payment option. * @param {number} paymentOptionId - The id of the selected payment option. * @param {string} flow - The online payment flow of the selected payment option. * @return {object} The extended transaction route params. */ - _prepareTransactionRouteParams: function (provider, paymentOptionId, flow) { + _prepareTransactionRouteParams: function (code, paymentOptionId, flow) { const transactionRouteParams = this._super(...arguments); return { ...transactionRouteParams, diff --git a/addons/account_payment/tests/common.py b/addons/account_payment/tests/common.py index 3529aa7e274..0e44e646c71 100644 --- a/addons/account_payment/tests/common.py +++ b/addons/account_payment/tests/common.py @@ -28,7 +28,7 @@ class AccountPaymentCommon(PaymentCommon, AccountTestInvoicingCommon): 'payment_type': 'inbound' }) - cls.dummy_acquirer.journal_id = cls.company_data['default_journal_bank'].id, + cls.dummy_provider.journal_id = cls.company_data['default_journal_bank'].id, cls.account = cls.company.account_journal_payment_credit_account_id cls.invoice = cls.env['account.move'].create({ @@ -60,23 +60,23 @@ class AccountPaymentCommon(PaymentCommon, AccountTestInvoicingCommon): #=== Utils ===# @classmethod - def _prepare_acquirer(cls, provider='none', company=None, update_values=None): - """ Override of `payment` to prepare and return the first acquirer matching the given + def _prepare_provider(cls, provider_code='none', company=None, update_values=None): + """ Override of `payment` to prepare and return the first provider matching the given provider and company. - If no acquirer is found in the given company, we duplicate the one from the base company. - All other acquirers belonging to the same company are disabled to avoid any interferences. + If no provider is found in the given company, we duplicate the one from the base company. + All other providers belonging to the same company are disabled to avoid any interferences. - :param str provider: The provider of the acquirer to prepare. - :param recordset company: The company of the acquirer to prepare, as a `res.company` record. - :param dict update_values: The values used to update the acquirer. - :return: The acquirer to prepare, if found. - :rtype: recordset of `payment.acquirer` + :param str provider_code: The code of the provider to prepare. + :param recordset company: The company of the provider to prepare, as a `res.company` record. + :param dict update_values: The values used to update the provider. + :return: The provider to prepare, if found. + :rtype: recordset of `payment.provider` """ - acquirer = super()._prepare_acquirer(provider, company, update_values) - if not acquirer.journal_id: - acquirer.journal_id = cls.env['account.journal'].search( - [('company_id', '=', acquirer.company_id.id), ('type', '=', 'bank')], + provider = super()._prepare_provider(provider_code, company, update_values) + if not provider.journal_id: + provider.journal_id = cls.env['account.journal'].search( + [('company_id', '=', provider.company_id.id), ('type', '=', 'bank')], limit=1, ) - return acquirer + return provider diff --git a/addons/account_payment/tests/test_account_payment.py b/addons/account_payment/tests/test_account_payment.py index 1734eb2fd3a..4b8fc12a3b7 100644 --- a/addons/account_payment/tests/test_account_payment.py +++ b/addons/account_payment/tests/test_account_payment.py @@ -11,18 +11,18 @@ from odoo.addons.account_payment.tests.common import AccountPaymentCommon class TestAccountPayment(AccountPaymentCommon): def test_no_amount_available_for_refund_when_not_supported(self): - self.acquirer.support_refund = False + self.provider.support_refund = False tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment self.assertEqual( tx.payment_id.amount_available_for_refund, 0, - msg="The value of `amount_available_for_refund` should be 0 when the acquirer doesn't " + msg="The value of `amount_available_for_refund` should be 0 when the provider doesn't " "support refunds." ) def test_full_amount_available_for_refund_when_not_yet_refunded(self): - self.acquirer.support_refund = 'full_only' # Should simply not be False + self.provider.support_refund = 'full_only' # Should simply not be False tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment self.assertAlmostEqual( @@ -34,7 +34,7 @@ class TestAccountPayment(AccountPaymentCommon): ) def test_full_amount_available_for_refund_when_refunds_are_pending(self): - self.acquirer.write({ + self.provider.write({ 'support_refund': 'full_only', # Should simply not be False 'support_manual_capture': True, # To create transaction in the 'authorized' state }) @@ -58,7 +58,7 @@ class TestAccountPayment(AccountPaymentCommon): ) def test_no_amount_available_for_refund_when_fully_refunded(self): - self.acquirer.support_refund = 'full_only' # Should simply not be False + self.provider.support_refund = 'full_only' # Should simply not be False tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment self._create_transaction( @@ -77,7 +77,7 @@ class TestAccountPayment(AccountPaymentCommon): ) def test_no_full_amount_available_for_refund_when_partially_refunded(self): - self.acquirer.support_refund = 'partial' + self.provider.support_refund = 'partial' tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment self._create_transaction( @@ -98,7 +98,7 @@ class TestAccountPayment(AccountPaymentCommon): ) def test_refunds_count(self): - self.acquirer.support_refund = 'full_only' # Should simply not be False + self.provider.support_refund = 'full_only' # Should simply not be False tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment for reference_index, operation in enumerate( @@ -127,7 +127,7 @@ class TestAccountPayment(AccountPaymentCommon): 'date': '2019-01-01', 'currency_id': self.currency.id, 'partner_id': self.partner.id, - 'journal_id': self.acquirer.journal_id.id, + 'journal_id': self.provider.journal_id.id, 'payment_method_line_id': self.inbound_payment_method_line.id, }) payment_with_token = payment_without_token.copy() diff --git a/addons/account_payment/tests/test_payment_flows.py b/addons/account_payment/tests/test_payment_flows.py index b5c76706d1d..329cb26d8f7 100644 --- a/addons/account_payment/tests/test_payment_flows.py +++ b/addons/account_payment/tests/test_payment_flows.py @@ -34,7 +34,7 @@ class TestFlows(AccountPaymentCommon, PaymentHttpCommon): } route_values.update({ 'flow': 'direct', - 'payment_option_id': self.acquirer.id, + 'payment_option_id': self.provider.id, 'tokenization_requested': False, }) with mute_logger('odoo.addons.payment.models.payment_transaction'): diff --git a/addons/account_payment/views/account_journal_views.xml b/addons/account_payment/views/account_journal_views.xml index f110be226c4..50013f77036 100644 --- a/addons/account_payment/views/account_journal_views.xml +++ b/addons/account_payment/views/account_journal_views.xml @@ -7,17 +7,17 @@ - - -