[IMP] payment{,_stripe},{,website_}sale: clean up stripe connect code

This commit removes deprecated actions and methods kept after the merge
of PR #79621 in stable.

Follow-up
task-2685160

closes odoo/odoo#84789

Related: odoo/upgrade#3256
Related: odoo/enterprise#25369
Signed-off-by: Thibault Libioulle (tle) <tle@odoo.com>
This commit is contained in:
Thibault Libioulle
2022-03-29 08:57:43 +02:00
parent 4c98b836d4
commit 2e7cc0d82f
13 changed files with 24 additions and 159 deletions
+1 -1
View File
@@ -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,
-14
View File
@@ -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.
+1 -1
View File
@@ -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
@@ -1,17 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- onboarding step -->
<template id="onboarding_payment_acquirer_step">
<t t-call="base.onboarding_step">
<t t-set="title">Online Payments</t>
<t t-set="description">Enable credit &amp; debit card payments supported by Stripe</t>
<t t-set="btn_text">Activate Stripe</t>
<t t-set="done_text">Online payments enabled</t>
<t t-set="method" t-value="'action_open_payment_onboarding_payment_acquirer'" />
<t t-set="model" t-value="'res.company'" />
<t t-set="state" t-value="state.get('payment_acquirer_onboarding_state')" />
</t>
</template>
<record model="ir.ui.view" id="payment_acquirer_onboarding_wizard_form">
<field name="name">payment.acquirer.onboarding.wizard.form</field>
@@ -42,24 +30,7 @@
</a>
</p>
</div>
<div invisible="1">
<group>
<field name="stripe_secret_key" password="True"/>
<field name="stripe_publishable_key" password="True"/>
</group>
<p>
<a href="https://dashboard.stripe.com/account/apikeys" target="_blank">
<span><i class="fa fa-arrow-right"/> Get my Stripe keys</span>
</a>
</p>
</div>
<div attrs="{'invisible': [('payment_method', '!=', 'other')]}">
<button type="object" name="action_onboarding_other_payment_acquirer">
Check here
</button>
to choose another payment method.
</div>
<div attrs="{'invisible': [('payment_method', '!=', 'manual')]}">
<group>
<field name="manual_name" attrs="{'required': [('payment_method', '=', 'manual')]}"/>
@@ -80,12 +51,4 @@
</field>
</record>
<record id="action_open_payment_onboarding_payment_acquirer_wizard" model="ir.actions.act_window">
<field name="name">Choose a payment method</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">payment.acquirer.onboarding.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="payment.payment_acquirer_onboarding_wizard_form" />
<field name="target">new</field>
</record>
</odoo>
@@ -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
@@ -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}')
+1 -13
View File
@@ -48,24 +48,12 @@
</t>
</template>
<!-- ORDER CONFIRMATION -->
<record id="sale_onboarding_order_confirmation_form" model="ir.ui.view">
<field name="name">sale.order.confirmation.onboarding.form</field>
<field name="model">sale.payment.acquirer.onboarding.wizard</field>
<field name="inherit_id" ref="payment.payment_acquirer_onboarding_wizard_form" />
<field name="mode">primary</field>
<field name="priority">1000</field>
<field name="arch" type="xml">
<xpath expr="//div[@name='left-column']" position="attributes">
<attribute name="class">col col-4</attribute>
</xpath>
</field>
</record>
<record id="action_open_sale_onboarding_payment_acquirer_wizard" model="ir.actions.act_window">
<field name="name">Choose how to confirm quotations</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.payment.acquirer.onboarding.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="sale_onboarding_order_confirmation_form" />
<field name="view_id" ref="payment.payment_acquirer_onboarding_wizard_form" />
<field name="target">new</field>
</record>
</odoo>
@@ -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. """
-1
View File
@@ -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',
@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
21 access_product_image_public product.image public model_product_image 1 0 0 0
22 access_product_image_publisher product.image wbesite publisher model_product_image website.group_website_publisher 1 1 1 1
23 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
24 access_ecom_extra_fields_public access_ecom_extra_field public model_website_sale_extra_field 1 0 0 0
25 access_ecom_extra_fields_publisher access_ecom_extra_field publisher model_website_sale_extra_field website.group_website_publisher 1 1 1 1
26 access_website_base_unit_public website.base.unit public model_website_base_unit 1 0 0 0
@@ -1,18 +0,0 @@
<odoo>
<!-- PAYMENT ACQUIRER -->
<template id="website_sale_onboarding_payment_acquirer_step" primary="True"
inherit_id="payment.onboarding_payment_acquirer_step">
<xpath expr="//t[@t-set='method']" position="replace">
<t t-set="method" t-value="'action_open_website_sale_onboarding_payment_acquirer'" />
</xpath>
</template>
<record id="action_open_website_sale_onboarding_payment_acquirer_wizard" model="ir.actions.act_window">
<field name="name">Choose a payment method</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">website.sale.payment.acquirer.onboarding.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="payment.payment_acquirer_onboarding_wizard_form" />
<field name="target">new</field>
</record>
</odoo>
-1
View File
@@ -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
@@ -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)