From 21d04d5cbc7514582667c6089e860dc02db63f39 Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Tue, 2 May 2023 17:34:32 +0200 Subject: [PATCH] [OU-ADD] website_blog: update blog_blog cover properties field This is the same as with the blog_post.cover_properties field. PR: https://github.com/OCA/OpenUpgrade/pull/3834 TT39016 --- .../website_blog/14.0.1.0/post-migration.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/openupgrade_scripts/scripts/website_blog/14.0.1.0/post-migration.py b/openupgrade_scripts/scripts/website_blog/14.0.1.0/post-migration.py index 6187954d64b..9baa205f799 100644 --- a/openupgrade_scripts/scripts/website_blog/14.0.1.0/post-migration.py +++ b/openupgrade_scripts/scripts/website_blog/14.0.1.0/post-migration.py @@ -3,16 +3,26 @@ from odoo.tools.json import scriptsafe as json_safe -def update_cover_properties_field(env): - blog_post = env["blog.post"].search([]) - for post in blog_post: - cover_properties = json_safe.loads(post.cover_properties) +def update_cover_properties_field(env, records): + for record in records: + cover_properties = json_safe.loads(record.cover_properties) cover_properties["background_color_class"] = "o_cc3" cover_properties.pop("background-color", None) - post.write({"cover_properties": json_safe.dumps(cover_properties)}) + record.write({"cover_properties": json_safe.dumps(cover_properties)}) + + +def blog_post_update_cover_properties_field(env): + blog_post = env["blog.post"].search([]) + update_cover_properties_field(env, blog_post) + + +def blog_blog_update_cover_properties_field(env): + blog_blog = env["blog.blog"].search([]) + update_cover_properties_field(env, blog_blog) @openupgrade.migrate() def migrate(env, version): openupgrade.load_data(env.cr, "website_blog", "14.0.1.0/noupdate_changes.xml") - update_cover_properties_field(env) + blog_post_update_cover_properties_field(env) + blog_blog_update_cover_properties_field(env)