Skip to content

Conversation

@marcelsavegnago
Copy link
Member

@marcelsavegnago marcelsavegnago commented Jan 21, 2026

Summary

This PR adds a new module website_blog_scheduled_publication that allows users to schedule blog posts for automatic publication at a specific date and time.

Features

  • Scheduled Publication Date: Adds a datetime field to blog posts for scheduling publication
  • Quick Publish Button: One-click immediate publication from the form view button box
  • Schedule Wizard: User-friendly wizard dialog to set the publication date
  • Visual Feedback: Information banner displays the scheduled date on the post form
  • Smart Publication Logic: Automatically prevents immediate publication if a future date is set
  • Automatic Cron Job: Runs every hour to check and publish scheduled posts
  • Notification System: Sends notifications to blog followers when posts are published
  • Search Filters: Filter posts by Published/Not Published status and group by Publication Date or Scheduled Publication Date

Technical Details

  • Extends blog.post model with new fields (scheduled_publication_date, schedule_type, next_departure) and methods
  • Includes a transient model blog.post.schedule.date for the scheduling wizard
  • Inherits and enhances form and search views from website_blog
  • Handles edge cases: setting past dates, clearing scheduled dates, multiple record writes
  • Comprehensive test coverage with 25+ test cases

Dependencies

  • website_blog

Test Plan

  • Install the module on a clean database
  • Create a blog post with a future scheduled date and verify it's not published immediately
  • Create a blog post with a past scheduled date and verify it publishes immediately
  • Test the Schedule wizard dialog
  • Test the Publish Now button
  • Run the cron job manually and verify scheduled posts are published
  • Verify notifications are sent to blog followers
  • Test search filters and grouping options
  • Run all unit tests: pytest website_blog_scheduled_publication/tests/

@yostashiro
Copy link
Member

@marcelsavegnago I guess you could take a similar approach as https://github.com/OCA/e-commerce/blob/15.0/website_sale_product_publish_date/models/product_template.py? I think there could even be a generic module with a mixin model which can be inherited by regular models if it fits the core architecture (I haven't taken a thorough look on it).

@marcelsavegnago marcelsavegnago force-pushed the 16.0-add-website_blog_scheduled_publication branch from bb858c1 to 90b624b Compare January 21, 2026 03:49
@marcelsavegnago
Copy link
Member Author

marcelsavegnago commented Jan 21, 2026

@marcelsavegnago I guess you could take a similar approach as https://github.com/OCA/e-commerce/blob/15.0/website_sale_product_publish_date/models/product_template.py? I think there could even be a generic module with a mixin model which can be inherited by regular models if it fits the core architecture (I haven't taken a thorough look on it).

@yostashiro You’re right — that approach looks like a solid reference point.

For now I’m handling a very specific case to solve the immediate need, but once I have a bit more time I’ll take a closer look and see if we can support a more generic solution (like a mixin / small reusable module) that fits well with the core architecture.

@marcelsavegnago marcelsavegnago force-pushed the 16.0-add-website_blog_scheduled_publication branch from aa545a8 to faa9210 Compare January 21, 2026 04:22
@marcelsavegnago marcelsavegnago marked this pull request as ready for review January 21, 2026 04:30
@marcelsavegnago marcelsavegnago force-pushed the 16.0-add-website_blog_scheduled_publication branch 5 times, most recently from c4dce31 to d06c485 Compare January 26, 2026 18:42
@marcelsavegnago marcelsavegnago force-pushed the 16.0-add-website_blog_scheduled_publication branch 2 times, most recently from e03ecbc to 6303ae2 Compare January 26, 2026 21:38
Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for you contribution!
Some note - not an issue - how about adding a calendar view for the blog.post model so it would be easier to see the scheduled posts?

"""Check if post has a future scheduled date."""
if post.scheduled_publication_date and post.scheduled_publication_date > now:
return True
scheduled_date = _to_datetime(vals.get("scheduled_publication_date"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: isn't scheduled_publication_date a Python datetime object already?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. When accessed from a record (post.scheduled_publication_date), it's already a datetime object. However, vals.get("scheduled_publication_date") can be a string when values come from forms, wizards, or API calls.
The _to_datetime() helper handles both cases safely — it converts strings to datetime and passes through datetime objects unchanged.
We're open to suggestions if you have a better approach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, let's leave as is for now. Would be good to add some comment in the code though to avoid same question in the future.

@marcelsavegnago marcelsavegnago force-pushed the 16.0-add-website_blog_scheduled_publication branch from 11510fa to ec379a3 Compare January 26, 2026 23:33
Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants