Skip to content

Commit

Permalink
[OU-ADD] website: extract footer copyright company name
Browse files Browse the repository at this point in the history
TT44254
  • Loading branch information
pilarvargas-tecnativa committed Jul 25, 2023
1 parent ff9528d commit 771580d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions openupgrade_scripts/scripts/website/15.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
import re

from openupgradelib import openupgrade


def extract_footer_copyright_company_name(env):
"""Replace Copyright content in the new v15 template so as not to lose
content from previous versions if it has been customised."""
main_copyright_view = env.ref("website.footer_copyright_company_name")
if not main_copyright_view:
return
main_copyright_arch = main_copyright_view.arch_db
main_copyright_pattern = r'<span class="o_footer_copyright_name mr-2">(.*?)<\/span>'
main_copyright_matches = re.findall(
main_copyright_pattern,
main_copyright_arch,
re.DOTALL,
)
website_layout_views = env["ir.ui.view"].search(
[("key", "=", "website.layout"), ("website_id", "!=", False)]
)
for view in website_layout_views:
website_layout_arch = view.arch_db
website_layout_pattern = (
r'<span class="o_footer_copyright_name mr-2">(.*?)<\/span>'
)
website_layout_matches = re.findall(
website_layout_pattern, website_layout_arch, re.DOTALL
)
if website_layout_matches:
new_arch = main_copyright_arch.replace(
main_copyright_matches[0], website_layout_matches[0]
)
main_copyright_view.copy(
{"website_id": view.website_id.id, "arch_db": new_arch}
)


def update_website_form_call(env):
# Update website views containing calls to "/website_form/" to "/website/form/"
views = env["ir.ui.view"].search([("arch_db", "like", 'action="/website_form/"')])
Expand All @@ -17,3 +52,4 @@ def migrate(env, version):
openupgrade.load_data(env.cr, "website", "15.0.1.0/noupdate_changes.xml")
openupgrade.delete_records_safely_by_xml_id(env, ["website.action_website_edit"])
update_website_form_call(env)
extract_footer_copyright_company_name(env)

0 comments on commit 771580d

Please sign in to comment.