diff --git a/addons/payment/__manifest__.py b/addons/payment/__manifest__.py index 0fdb29b9a22..241c9c32c0c 100644 --- a/addons/payment/__manifest__.py +++ b/addons/payment/__manifest__.py @@ -28,8 +28,8 @@ 'security/payment_security.xml', 'wizards/account_payment_register_views.xml', - 'wizards/payment_acquirer_onboarding_templates.xml', 'wizards/payment_link_wizard_views.xml', + 'wizards/payment_onboarding_views.xml', 'wizards/payment_refund_wizard_views.xml', ], 'auto_install': True, diff --git a/addons/payment/models/res_company.py b/addons/payment/models/res_company.py index 39ec3960f4b..65f0584d4b5 100644 --- a/addons/payment/models/res_company.py +++ b/addons/payment/models/res_company.py @@ -19,20 +19,6 @@ class ResCompany(models.Model): ('other', "Other"), ]) - @api.model - def action_open_payment_onboarding_payment_acquirer(self): - """ Called by onboarding panel above the customer invoice list. """ - # TODO remove me in master. - # This action is never used anywhere because the onboarding step's method is overridden in - # website_sale to call action_open_website_sale_onboarding_payment_acquirer instead. - # Fail if there are no existing accounts - self.env.company.get_chart_of_accounts_or_fail() - - action = self.env['ir.actions.actions']._for_xml_id( - 'payment.action_open_payment_onboarding_payment_acquirer_wizard' - ) - return action - def _run_payment_onboarding_step(self, menu_id): """ Install the suggested payment modules and configure the acquirers. diff --git a/addons/payment/wizards/__init__.py b/addons/payment/wizards/__init__.py index 58f56810673..9fe986bcd33 100644 --- a/addons/payment/wizards/__init__.py +++ b/addons/payment/wizards/__init__.py @@ -1,6 +1,6 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import account_payment_register -from . import payment_acquirer_onboarding_wizard from . import payment_link_wizard +from . import payment_onboarding_wizard from . import payment_refund_wizard diff --git a/addons/payment/wizards/payment_acquirer_onboarding_templates.xml b/addons/payment/wizards/payment_onboarding_views.xml similarity index 62% rename from addons/payment/wizards/payment_acquirer_onboarding_templates.xml rename to addons/payment/wizards/payment_onboarding_views.xml index 8e293da024a..b6258976125 100644 --- a/addons/payment/wizards/payment_acquirer_onboarding_templates.xml +++ b/addons/payment/wizards/payment_onboarding_views.xml @@ -1,17 +1,5 @@ - - payment.acquirer.onboarding.wizard.form @@ -42,24 +30,7 @@

-
- - - - -

- - Get my Stripe keys - -

-
-
- - to choose another payment method. -
@@ -80,12 +51,4 @@ - - Choose a payment method - ir.actions.act_window - payment.acquirer.onboarding.wizard - form - - new - diff --git a/addons/payment/wizards/payment_acquirer_onboarding_wizard.py b/addons/payment/wizards/payment_onboarding_wizard.py similarity index 73% rename from addons/payment/wizards/payment_acquirer_onboarding_wizard.py rename to addons/payment/wizards/payment_onboarding_wizard.py index 3390df26fa2..7128a5a4508 100644 --- a/addons/payment/wizards/payment_acquirer_onboarding_wizard.py +++ b/addons/payment/wizards/payment_onboarding_wizard.py @@ -9,9 +9,8 @@ class PaymentWizard(models.TransientModel): _description = 'Payment acquire onboarding wizard' payment_method = fields.Selection([ + ('stripe', "Credit & Debit card (via Stripe)"), ('paypal', "PayPal"), - ('stripe', "Credit card (via Stripe)"), - ('other', "Other payment acquirer"), ('manual', "Custom payment instructions"), ], string="Payment Method", default=lambda self: self._get_default_payment_acquirer_onboarding_value('payment_method')) @@ -22,9 +21,6 @@ class PaymentWizard(models.TransientModel): paypal_seller_account = fields.Char("Merchant Account ID", default=lambda self: self._get_default_payment_acquirer_onboarding_value('paypal_seller_account')) paypal_pdt_token = fields.Char("PDT Identity Token", default=lambda self: self._get_default_payment_acquirer_onboarding_value('paypal_pdt_token')) - stripe_secret_key = fields.Char(default=lambda self: self._get_default_payment_acquirer_onboarding_value('stripe_secret_key')) - stripe_publishable_key = fields.Char(default=lambda self: self._get_default_payment_acquirer_onboarding_value('stripe_publishable_key')) - manual_name = fields.Char("Method", default=lambda self: self._get_default_payment_acquirer_onboarding_value('manual_name')) journal_name = fields.Char("Bank Name", default=lambda self: self._get_default_payment_acquirer_onboarding_value('journal_name')) acc_number = fields.Char("Account Number", default=lambda self: self._get_default_payment_acquirer_onboarding_value('acc_number')) @@ -72,11 +68,6 @@ class PaymentWizard(models.TransientModel): self._payment_acquirer_onboarding_cache['paypal_seller_account'] = acquirer['paypal_seller_account'] self._payment_acquirer_onboarding_cache['paypal_pdt_token'] = acquirer['paypal_pdt_token'] - if 'payment_stripe' in installed_modules: - acquirer = self.env.ref('payment.payment_acquirer_stripe') - self._payment_acquirer_onboarding_cache['stripe_secret_key'] = acquirer['stripe_secret_key'] - self._payment_acquirer_onboarding_cache['stripe_publishable_key'] = acquirer['stripe_publishable_key'] - manual_payment = self._get_manual_payment_acquirer() journal = manual_payment.journal_id @@ -87,33 +78,17 @@ class PaymentWizard(models.TransientModel): return self._payment_acquirer_onboarding_cache.get(key, '') - def _install_module(self, module_name): - module = self.env['ir.module.module'].sudo().search([('name', '=', module_name)]) - if module.state not in ('installed', 'to install', 'to upgrade'): - module.button_immediate_install() - - def _on_save_payment_acquirer(self): - self._install_module('account_payment') - def add_payment_methods(self): - """ Install required payment acquiers, configure them and mark the + """ Install required payment acquirers, configure them and mark the onboarding step as done.""" - if self.payment_method == 'stripe' and not self.stripe_publishable_key: - self.env.company.payment_onboarding_payment_method = self.payment_method - return self._start_stripe_onboarding() + payment_method = self.payment_method if self.payment_method == 'paypal': - self._install_module('payment_paypal') - - if self.payment_method == 'stripe': - self._install_module('payment_stripe') - - if self.payment_method in ('paypal', 'stripe', 'manual', 'other'): - - self._on_save_payment_acquirer() - - self.env.company.payment_onboarding_payment_method = self.payment_method + self.env.company._install_modules(['payment_paypal', 'account_payment']) + elif self.payment_method == 'manual': + self.env.company._install_modules(['account_payment']) + if self.payment_method in ('paypal', 'manual'): # create a new env including the freshly installed module(s) new_env = api.Environment(self.env.cr, self.env.uid, self.env.context) @@ -124,13 +99,7 @@ class PaymentWizard(models.TransientModel): 'paypal_pdt_token': self.paypal_pdt_token, 'state': 'enabled', }) - if self.payment_method == 'stripe': - new_env.ref('payment.payment_acquirer_stripe').write({ - 'stripe_secret_key': self.stripe_secret_key, - 'stripe_publishable_key': self.stripe_publishable_key, - 'state': 'enabled', - }) - if self.payment_method == 'manual': + elif self.payment_method == 'manual': manual_acquirer = self._get_manual_payment_acquirer(new_env) if not manual_acquirer: raise UserError(_( @@ -146,8 +115,15 @@ class PaymentWizard(models.TransientModel): journal.name = self.journal_name journal.bank_acc_number = self.acc_number - # delete wizard data immediately to get rid of residual credentials - self.sudo().unlink() + if self.payment_method in ('paypal', 'manual', 'stripe'): + self.env.company.payment_onboarding_payment_method = self.payment_method + + # delete wizard data immediately to get rid of residual credentials + self.sudo().unlink() + + if payment_method == 'stripe': + return self._start_stripe_onboarding() + # the user clicked `apply` and not cancel so we can assume this step is done. self._set_payment_acquirer_onboarding_step_done() return {'type': 'ir.actions.act_window_close'} @@ -155,11 +131,6 @@ class PaymentWizard(models.TransientModel): def _set_payment_acquirer_onboarding_step_done(self): self.env.company.sudo().set_onboarding_step_done('payment_acquirer_onboarding_state') - def action_onboarding_other_payment_acquirer(self): - self._set_payment_acquirer_onboarding_step_done() - action = self.env["ir.actions.actions"]._for_xml_id("payment.action_payment_acquirer") - return action - def _start_stripe_onboarding(self): """ Start Stripe Connect onboarding. """ menu_id = self.env.ref('payment.payment_acquirer_menu').id diff --git a/addons/payment_stripe/controllers/onboarding.py b/addons/payment_stripe/controllers/onboarding.py index 90040ecf8f5..0fedfa2f9fc 100644 --- a/addons/payment_stripe/controllers/onboarding.py +++ b/addons/payment_stripe/controllers/onboarding.py @@ -24,9 +24,7 @@ class OnboardingController(http.Controller): """ stripe_acquirer = request.env['payment.acquirer'].browse(int(acquirer_id)) stripe_acquirer.company_id._mark_payment_onboarding_step_as_done() - action = request.env.ref( - 'payment_stripe.action_payment_acquirer_onboarding', raise_if_not_found=False - ) or request.env.ref('payment.action_payment_acquirer') + action = request.env.ref('payment_stripe.action_payment_acquirer_onboarding') get_params_string = url_encode({'action': action.id, 'id': acquirer_id, 'menu_id': menu_id}) return request.redirect(f'/web?#{get_params_string}') diff --git a/addons/sale/views/sale_onboarding_views.xml b/addons/sale/views/sale_onboarding_views.xml index 55d6dc20826..8269aa2a50a 100644 --- a/addons/sale/views/sale_onboarding_views.xml +++ b/addons/sale/views/sale_onboarding_views.xml @@ -48,24 +48,12 @@ - - sale.order.confirmation.onboarding.form - sale.payment.acquirer.onboarding.wizard - - primary - 1000 - - - col col-4 - - - Choose how to confirm quotations ir.actions.act_window sale.payment.acquirer.onboarding.wizard form - + new diff --git a/addons/sale/wizard/payment_acquirer_onboarding_wizard.py b/addons/sale/wizard/payment_acquirer_onboarding_wizard.py index 70fb12a03b3..8a492b6c606 100644 --- a/addons/sale/wizard/payment_acquirer_onboarding_wizard.py +++ b/addons/sale/wizard/payment_acquirer_onboarding_wizard.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import fields, models class PaymentWizard(models.TransientModel): @@ -18,7 +18,6 @@ class PaymentWizard(models.TransientModel): ('digital_signature', "Electronic signature"), ('stripe', "Credit & Debit card (via Stripe)"), ('paypal', "PayPal"), - ('other', "Other payment acquirer"), ('manual', "Custom payment instructions"), ], default=_get_default_payment_method) # @@ -27,14 +26,14 @@ class PaymentWizard(models.TransientModel): """ Override. """ self.env.company.sudo().set_onboarding_step_done('sale_onboarding_order_confirmation_state') - def add_payment_methods(self, *args, **kwargs): + def add_payment_methods(self): self.env.company.sale_onboarding_payment_method = self.payment_method if self.payment_method == 'digital_signature': self.env.company.portal_confirmation_sign = True if self.payment_method in ('paypal', 'stripe', 'other', 'manual'): self.env.company.portal_confirmation_pay = True - return super(PaymentWizard, self).add_payment_methods(*args, **kwargs) + return super().add_payment_methods() def _start_stripe_onboarding(self): """ Override of payment to set the sale menu as start menu of the payment onboarding. """ diff --git a/addons/website_sale/__manifest__.py b/addons/website_sale/__manifest__.py index 3c747901ed1..d7144330e44 100644 --- a/addons/website_sale/__manifest__.py +++ b/addons/website_sale/__manifest__.py @@ -21,7 +21,6 @@ 'views/product_tag_views.xml', 'views/product_views.xml', 'views/account_views.xml', - 'views/onboarding_views.xml', 'views/sale_report_views.xml', 'views/sale_order_views.xml', 'views/crm_team_views.xml', diff --git a/addons/website_sale/security/ir.model.access.csv b/addons/website_sale/security/ir.model.access.csv index 14fbacae91b..e8fa9c20889 100644 --- a/addons/website_sale/security/ir.model.access.csv +++ b/addons/website_sale/security/ir.model.access.csv @@ -21,7 +21,6 @@ access_account_tax_user,account.tax,account.model_account_tax,base.group_public, access_product_image_public,product.image public,model_product_image,,1,0,0,0 access_product_image_publisher,product.image wbesite publisher,model_product_image,website.group_website_publisher,1,1,1,1 access_product_image_sale,product.image sale,model_product_image,sales_team.group_sale_manager,1,1,1,1 -access_website_sale_payment_acquirer_onboarding_wizard,access.website.sale.payment.acquirer.onboarding.wizard,model_website_sale_payment_acquirer_onboarding_wizard,base.group_system,1,1,1,0 access_ecom_extra_fields_public,access_ecom_extra_field public,model_website_sale_extra_field,,1,0,0,0 access_ecom_extra_fields_publisher,access_ecom_extra_field publisher,model_website_sale_extra_field,website.group_website_publisher,1,1,1,1 access_website_base_unit_public,website.base.unit public,model_website_base_unit,,1,0,0,0 diff --git a/addons/website_sale/views/onboarding_views.xml b/addons/website_sale/views/onboarding_views.xml deleted file mode 100644 index 8414ab391ad..00000000000 --- a/addons/website_sale/views/onboarding_views.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Choose a payment method - ir.actions.act_window - website.sale.payment.acquirer.onboarding.wizard - form - - new - - diff --git a/addons/website_sale/wizard/__init__.py b/addons/website_sale/wizard/__init__.py index 5da2d9f4b7f..2cd60f0085a 100644 --- a/addons/website_sale/wizard/__init__.py +++ b/addons/website_sale/wizard/__init__.py @@ -2,4 +2,3 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import mail_compose_message -from . import payment_acquirer_onboarding_wizard diff --git a/addons/website_sale/wizard/payment_acquirer_onboarding_wizard.py b/addons/website_sale/wizard/payment_acquirer_onboarding_wizard.py deleted file mode 100644 index c7c28f010b3..00000000000 --- a/addons/website_sale/wizard/payment_acquirer_onboarding_wizard.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import models - - -class PaymentWizard(models.TransientModel): - _inherit = 'payment.acquirer.onboarding.wizard' - _name = 'website.sale.payment.acquirer.onboarding.wizard' - _description = 'Website Payment acquire onboarding wizard' - - def _set_payment_acquirer_onboarding_step_done(self): - """ Override. """ - self.env.company.sudo().set_onboarding_step_done('payment_acquirer_onboarding_state') - - def _start_stripe_onboarding(self): - """ Override of payment to set the dashboard as start menu of the payment onboarding. """ - menu_id = self.env.ref('website.menu_website_dashboard').id - return self.env.company._run_payment_onboarding_step(menu_id)