Skip to content

Commit

Permalink
Merge pull request #3843 from Tecnativa/14.0-ou-add-website_blog-upda…
Browse files Browse the repository at this point in the history
…te_cover_properties-blog_blog

[15.0][OU-ADD] website_blog: update blog_blog cover properties field
  • Loading branch information
pedrobaeza authored May 2, 2023
2 parents 6fded25 + 21d04d5 commit e0f2cfe
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit e0f2cfe

Please sign in to comment.