* = account{_payment}, base, onboarding, payment{_stripe},
sale{_management}, web, website_sale
Use the dedicated onboarding module introduced in 16.0 instead of
the res.company model to store onboarding progress.
It allows
* onboarding steps to be reused across panels
* to support steps that should be completed per-database or per-company
* to clean the res.company model from many fields and methods,
* to remove many views, controllers, actions
Module-specific notes:
* account: We also clean the remaining two steps that are not
part of an accounting panel but make the most sense to be kept here.
* account_payment: Following 8e4e8eb8, the payment provider step is
added to the invoicing onboarding panel. We apply this change here too.
Also impacts the website_sale_dashboard panel (see related ENT PR).
(The "sale tax" one is currently used for to the website sale dashboard).
* payment: Note that the step was already not part of an onboarding
panel within this module.
* website_sale: We clean
* a field not used (The website_sale dashboard onboarding panel used
the payment_provider_onboarding_state field).
* a method that was only called from website_sale_dashboard, so it is
moved there. See related ENT PR.
Includes a few tests.
Moving views/templates/styling, as well as cleaning residual onboarding-related fields and methods in base, including populate.
This also includes restoring the "onboarding_complete" overlay panel
animating it to disappear after a few seconds so that it doesn't hide
text and block buttons to re-open steps.
Task-3025136
Part-of: odoo/odoo#104223
55 lines
2.2 KiB
Python
55 lines
2.2 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class ResCompany(models.Model):
|
|
_inherit = 'res.company'
|
|
|
|
payment_onboarding_payment_method = fields.Selection(
|
|
string="Selected onboarding payment method",
|
|
selection=[
|
|
('paypal', "PayPal"),
|
|
('stripe', "Stripe"),
|
|
('manual', "Manual"),
|
|
('other', "Other"),
|
|
])
|
|
|
|
def _run_payment_onboarding_step(self, menu_id):
|
|
""" Install the suggested payment modules and configure the providers.
|
|
|
|
It's checked that the current company has a Chart of Account.
|
|
|
|
:param int menu_id: The menu from which the user started the onboarding step, as an
|
|
`ir.ui.menu` id
|
|
:return: The action returned by `action_stripe_connect_account`
|
|
:rtype: dict
|
|
"""
|
|
self.env.company.get_chart_of_accounts_or_fail()
|
|
|
|
self._install_modules(['payment_stripe', 'account_payment'])
|
|
|
|
# Create a new env including the freshly installed module(s)
|
|
new_env = api.Environment(self.env.cr, self.env.uid, self.env.context)
|
|
|
|
# Configure Stripe
|
|
default_journal = new_env['account.journal'].search(
|
|
[('type', '=', 'bank'), ('company_id', '=', new_env.company.id)], limit=1
|
|
)
|
|
|
|
stripe_provider = new_env['payment.provider'].search(
|
|
[('company_id', '=', self.env.company.id), ('code', '=', 'stripe')], limit=1
|
|
)
|
|
if not stripe_provider:
|
|
base_provider = self.env.ref('payment.payment_provider_stripe')
|
|
# Use sudo to access payment provider record that can be in different company.
|
|
stripe_provider = base_provider.sudo().copy(default={'company_id': self.env.company.id})
|
|
stripe_provider.journal_id = stripe_provider.journal_id or default_journal
|
|
|
|
return stripe_provider.action_stripe_connect_account(menu_id=menu_id)
|
|
|
|
def _install_modules(self, module_names):
|
|
modules_sudo = self.env['ir.module.module'].sudo().search([('name', 'in', module_names)])
|
|
STATES = ['installed', 'to install', 'to upgrade']
|
|
modules_sudo.filtered(lambda m: m.state not in STATES).button_immediate_install()
|