forked from OCA/OpenUpgrade
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OCA#4242 from Tecnativa/15.0-mig-website_crm
[15.0][OU-ADD] website_crm: Migrate website_crm views
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
openupgrade_scripts/scripts/website_crm/15.0.2.1/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2023 Tecnativa - Pilar Vargas | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def migrate_website_crm_views(env): | ||
"""Update the arch_db field by replacing the occurrences of "mail.mail" with "crm.lead" | ||
in "website.contactus". This is done to adapt the functionality in Odoo v15 where the | ||
default action is used to send an email and to ensure that the configuration is not | ||
lost for the that the configuration is not lost to create an opportunity that in previous | ||
versions was configured by default by a was configured by default by a replacement in | ||
the form view.""" | ||
for website in env["website"].search([]): | ||
website_contactus_view = website.with_context(website_id=website.id).viewref( | ||
"website.contactus" | ||
) | ||
website_contactus_arch_db = website_contactus_view.arch_db | ||
if 'data-model_name="mail.mail"' in website_contactus_arch_db: | ||
new_arch = website_contactus_arch_db.replace( | ||
'data-model_name="mail.mail"', 'data-model_name="crm.lead"' | ||
) | ||
website_contactus_view.with_context(website_id=website.id).arch = new_arch | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
migrate_website_crm_views(env) |