From 6da6909f735b0f58d192f377d7c62f85e76c91c6 Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Wed, 21 Jan 2026 16:57:04 -0300 Subject: [PATCH] [ADD] website_blog_usability: add new module --- .../odoo/addons/website_blog_usability | 1 + setup/website_blog_usability/setup.py | 6 + website_blog_usability/README.rst | 186 ++++++++++++++++++ website_blog_usability/__init__.py | 4 + website_blog_usability/__manifest__.py | 22 +++ website_blog_usability/models/__init__.py | 4 + website_blog_usability/models/blog_post.py | 19 ++ website_blog_usability/readme/CONFIGURE.rst | 22 +++ .../readme/CONTRIBUTORS.rst | 3 + website_blog_usability/readme/DESCRIPTION.rst | 32 +++ website_blog_usability/readme/USAGE.rst | 39 ++++ .../static/description/index.html | 27 +++ website_blog_usability/tests/__init__.py | 4 + .../tests/test_blog_post_usability.py | 56 ++++++ .../views/blog_post_views.xml | 124 ++++++++++++ 15 files changed, 549 insertions(+) create mode 120000 setup/website_blog_usability/odoo/addons/website_blog_usability create mode 100644 setup/website_blog_usability/setup.py create mode 100644 website_blog_usability/README.rst create mode 100644 website_blog_usability/__init__.py create mode 100644 website_blog_usability/__manifest__.py create mode 100644 website_blog_usability/models/__init__.py create mode 100644 website_blog_usability/models/blog_post.py create mode 100644 website_blog_usability/readme/CONFIGURE.rst create mode 100644 website_blog_usability/readme/CONTRIBUTORS.rst create mode 100644 website_blog_usability/readme/DESCRIPTION.rst create mode 100644 website_blog_usability/readme/USAGE.rst create mode 100644 website_blog_usability/static/description/index.html create mode 100644 website_blog_usability/tests/__init__.py create mode 100644 website_blog_usability/tests/test_blog_post_usability.py create mode 100644 website_blog_usability/views/blog_post_views.xml diff --git a/setup/website_blog_usability/odoo/addons/website_blog_usability b/setup/website_blog_usability/odoo/addons/website_blog_usability new file mode 120000 index 0000000000..d26ef47906 --- /dev/null +++ b/setup/website_blog_usability/odoo/addons/website_blog_usability @@ -0,0 +1 @@ +../../../../website_blog_usability \ No newline at end of file diff --git a/setup/website_blog_usability/setup.py b/setup/website_blog_usability/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_blog_usability/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_blog_usability/README.rst b/website_blog_usability/README.rst new file mode 100644 index 0000000000..22f6e1e337 --- /dev/null +++ b/website_blog_usability/README.rst @@ -0,0 +1,186 @@ +====================== +Website Blog Usability +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:91072b61abd6f73d3999e81d5ce5ef25a75de77580a7c9258186ad79b5294861 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwebsite-lightgray.png?logo=github + :target: https://github.com/OCA/website/tree/16.0/website_blog_usability + :alt: OCA/website +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/website-16-0/website-16-0-website_blog_usability + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/website&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module enhances the blog management capabilities in Odoo by adding professional features for better content management. + +Features +-------- + +* **Visits Display**: Show visit counts in list, form, and kanban views +* **Backend Form Access**: Quick access button (gear icon) in list view to open post form in backend +* **Professional Editing**: Content tab with HTML editor supporting code view toggle +* **Enhanced Views**: Improved form, tree, and kanban views with visit information +* **Search Filters**: Filter posts with no visits + +Usage +----- + +After installing this module: + +1. Navigate to **Website > Content > Blog Posts** +2. View visit counts in the list view (visits column) +3. Click the gear icon button next to a post name to open it in backend form view +4. Use the enhanced form view to edit posts with HTML/code toggle in the Content tab +5. Filter posts with no visits using the search filter +6. View visit counts in kanban cards + +Technical Details +----------------- + +* Extends `blog.post` model with method `action_open_backend_form()` to open backend form view +* Inherits and enhances existing views from `website_blog`: + * Form view: Adds statistics section with visits and Content tab with HTML editor + * Tree view: Adds visits column, post_date column, and backend form button + * Search view: Adds "No Visits" filter + * Kanban view: Displays visit count in cards + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To use this module, you need to: + +#. Install the module from Apps menu +#. Go to **Website > Content > Blog Posts** +#. The module automatically enhances the blog post views with: + + * Visit counts displayed in list, form, and kanban views + * Backend form access button (gear icon) in list view + * Statistics section in form view showing visit count + * Content editing tab with HTML/code toggle capability + * Search filter for posts with no visits + +#. Create or edit a blog post to see the enhanced features: + + * In the form view, you'll see a new "Statistics" section with visit information + * A new "Content" tab in the notebook allows editing with HTML/code toggle + * In the list view, visit counts are displayed and you can click the gear icon to open backend form + * Use search filter "No Visits" to find posts that haven't been visited yet + +#. The visit counts are automatically tracked when visitors view blog posts on the website + +Note: Visit counts are incremented automatically by the website_blog module when posts are viewed. This module only enhances the display and management of this information. + +Usage +===== + +Usage Guide +=========== + +Viewing Visit Statistics +------------------------ + +After installing the module, visit counts are automatically displayed: + +* **List View**: The visits column shows the total number of views for each post +* **Form View**: A new "Statistics" section displays: + * Total visits (editable) + * Creation and last update dates +* **Kanban View**: Visit count is displayed in each card with an eye icon + +Accessing Backend Form +---------------------- + +In the list view, each post has a gear icon button next to its name: + +* Click the gear icon to open the post form view in the backend +* This allows quick access to edit posts without navigating to the website +* The button opens the form view in the current window + +Filtering Posts +--------------- + +Use the search filters to find posts: + +* **No Visits**: Shows posts that haven't been visited yet (visits = 0) + +Editing Content +--------------- + +The module adds a "Content" tab in the blog post form view: + +* Edit blog post content with HTML visual editor +* Toggle to code view for direct HTML editing +* The editor supports syntax highlighting for HTML +* Use the ACE editor options to switch between visual and code modes + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Marcel Savegnago + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px + :target: https://github.com/marcelsavegnago + :alt: marcelsavegnago + +Current `maintainer `__: + +|maintainer-marcelsavegnago| + +This module is part of the `OCA/website `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_blog_usability/__init__.py b/website_blog_usability/__init__.py new file mode 100644 index 0000000000..f6de863519 --- /dev/null +++ b/website_blog_usability/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 - TODAY, Escodoo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/website_blog_usability/__manifest__.py b/website_blog_usability/__manifest__.py new file mode 100644 index 0000000000..f40f8cd1bc --- /dev/null +++ b/website_blog_usability/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2026 - TODAY, Escodoo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Website Blog Usability", + "summary": "Enhanced blog management with visits display, backend form " + "access, and HTML/code editing", + "version": "16.0.1.0.0", + "author": "Escodoo, Odoo Community Association (OCA)", + "maintainers": ["marcelsavegnago"], + "license": "AGPL-3", + "category": "Website", + "website": "https://github.com/OCA/website", + "depends": [ + "website_blog", + ], + "data": [ + "views/blog_post_views.xml", + ], + "installable": True, + "application": False, +} diff --git a/website_blog_usability/models/__init__.py b/website_blog_usability/models/__init__.py new file mode 100644 index 0000000000..d4c6e9012d --- /dev/null +++ b/website_blog_usability/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 - TODAY, Escodoo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import blog_post diff --git a/website_blog_usability/models/blog_post.py b/website_blog_usability/models/blog_post.py new file mode 100644 index 0000000000..7540ada41f --- /dev/null +++ b/website_blog_usability/models/blog_post.py @@ -0,0 +1,19 @@ +# Copyright 2026 - TODAY, Marcel Savegnago +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class BlogPost(models.Model): + _inherit = "blog.post" + + def action_open_backend_form(self): + """Open the blog post form view in backend.""" + self.ensure_one() + return { + "type": "ir.actions.act_window", + "res_model": "blog.post", + "res_id": self.id, + "view_mode": "form", + "target": "current", + } diff --git a/website_blog_usability/readme/CONFIGURE.rst b/website_blog_usability/readme/CONFIGURE.rst new file mode 100644 index 0000000000..f88731b7af --- /dev/null +++ b/website_blog_usability/readme/CONFIGURE.rst @@ -0,0 +1,22 @@ +To use this module, you need to: + +#. Install the module from Apps menu +#. Go to **Website > Content > Blog Posts** +#. The module automatically enhances the blog post views with: + + * Visit counts displayed in list, form, and kanban views + * Backend form access button (gear icon) in list view + * Statistics section in form view showing visit count + * Content editing tab with HTML/code toggle capability + * Search filter for posts with no visits + +#. Create or edit a blog post to see the enhanced features: + + * In the form view, you'll see a new "Statistics" section with visit information + * A new "Content" tab in the notebook allows editing with HTML/code toggle + * In the list view, visit counts are displayed and you can click the gear icon to open backend form + * Use search filter "No Visits" to find posts that haven't been visited yet + +#. The visit counts are automatically tracked when visitors view blog posts on the website + +Note: Visit counts are incremented automatically by the website_blog module when posts are viewed. This module only enhances the display and management of this information. diff --git a/website_blog_usability/readme/CONTRIBUTORS.rst b/website_blog_usability/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..ae453a60bd --- /dev/null +++ b/website_blog_usability/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Escodoo `_: + + * Marcel Savegnago diff --git a/website_blog_usability/readme/DESCRIPTION.rst b/website_blog_usability/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..1e0846d4f0 --- /dev/null +++ b/website_blog_usability/readme/DESCRIPTION.rst @@ -0,0 +1,32 @@ +This module enhances the blog management capabilities in Odoo by adding professional features for better content management. + +Features +-------- + +* **Visits Display**: Show visit counts in list, form, and kanban views +* **Backend Form Access**: Quick access button (gear icon) in list view to open post form in backend +* **Professional Editing**: Content tab with HTML editor supporting code view toggle +* **Enhanced Views**: Improved form, tree, and kanban views with visit information +* **Search Filters**: Filter posts with no visits + +Usage +----- + +After installing this module: + +1. Navigate to **Website > Content > Blog Posts** +2. View visit counts in the list view (visits column) +3. Click the gear icon button next to a post name to open it in backend form view +4. Use the enhanced form view to edit posts with HTML/code toggle in the Content tab +5. Filter posts with no visits using the search filter +6. View visit counts in kanban cards + +Technical Details +----------------- + +* Extends `blog.post` model with method `action_open_backend_form()` to open backend form view +* Inherits and enhances existing views from `website_blog`: + * Form view: Adds statistics section with visits and Content tab with HTML editor + * Tree view: Adds visits column, post_date column, and backend form button + * Search view: Adds "No Visits" filter + * Kanban view: Displays visit count in cards diff --git a/website_blog_usability/readme/USAGE.rst b/website_blog_usability/readme/USAGE.rst new file mode 100644 index 0000000000..5f89c69c67 --- /dev/null +++ b/website_blog_usability/readme/USAGE.rst @@ -0,0 +1,39 @@ +Usage Guide +=========== + +Viewing Visit Statistics +------------------------ + +After installing the module, visit counts are automatically displayed: + +* **List View**: The visits column shows the total number of views for each post +* **Form View**: A new "Statistics" section displays: + * Total visits (editable) + * Creation and last update dates +* **Kanban View**: Visit count is displayed in each card with an eye icon + +Accessing Backend Form +---------------------- + +In the list view, each post has a gear icon button next to its name: + +* Click the gear icon to open the post form view in the backend +* This allows quick access to edit posts without navigating to the website +* The button opens the form view in the current window + +Filtering Posts +--------------- + +Use the search filters to find posts: + +* **No Visits**: Shows posts that haven't been visited yet (visits = 0) + +Editing Content +--------------- + +The module adds a "Content" tab in the blog post form view: + +* Edit blog post content with HTML visual editor +* Toggle to code view for direct HTML editing +* The editor supports syntax highlighting for HTML +* Use the ACE editor options to switch between visual and code modes diff --git a/website_blog_usability/static/description/index.html b/website_blog_usability/static/description/index.html new file mode 100644 index 0000000000..a40e70fffc --- /dev/null +++ b/website_blog_usability/static/description/index.html @@ -0,0 +1,27 @@ + + + + + Website Blog Usability + + +
+
+

Website Blog Usability

+

Enhanced blog management with professional features

+
+

+ This module enhances the blog management capabilities by adding: +

+
    +
  • Visit counts display in list, form, and kanban views
  • +
  • Backend form access button (gear icon) for quick editing
  • +
  • Content editing tab with HTML/code toggle
  • +
  • Statistics section in form view
  • +
  • Search filters for posts with no visits
  • +
+
+
+
+ + diff --git a/website_blog_usability/tests/__init__.py b/website_blog_usability/tests/__init__.py new file mode 100644 index 0000000000..10eea7c484 --- /dev/null +++ b/website_blog_usability/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 - TODAY, Marcel Savegnago +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_blog_post_usability diff --git a/website_blog_usability/tests/test_blog_post_usability.py b/website_blog_usability/tests/test_blog_post_usability.py new file mode 100644 index 0000000000..76780ef153 --- /dev/null +++ b/website_blog_usability/tests/test_blog_post_usability.py @@ -0,0 +1,56 @@ +# Copyright 2026 - TODAY, Marcel Savegnago +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestBlogPostUsability(TransactionCase): + def setUp(self): + super().setUp() + # Create a blog + self.blog = self.env["blog.blog"].create({"name": "Test Blog"}) + # Create a user with blog manager rights + group_blog_manager = self.env.ref("website.group_website_designer") + self.user_blogmanager = ( + self.env["res.users"] + .with_context(no_reset_password=True) + .create( + { + "name": "Blog Manager", + "login": "blog_manager", + "email": "blog.manager@example.com", + "groups_id": [(6, 0, [group_blog_manager.id])], + } + ) + ) + # Create a test blog post + self.blog_post = ( + self.env["blog.post"] + .with_user(self.user_blogmanager) + .with_context(mail_create_nolog=True) + .create( + { + "name": "Test Blog Post", + "blog_id": self.blog.id, + "content": "

Test content

", + } + ) + ) + + def test_action_open_backend_form(self): + """Test that action_open_backend_form returns correct action.""" + # Test with single record (ensure_one is called) + action = self.blog_post.action_open_backend_form() + self.assertIsNotNone(action) + self.assertEqual(action["type"], "ir.actions.act_window") + self.assertEqual(action["res_model"], "blog.post") + self.assertEqual(action["res_id"], self.blog_post.id) + self.assertEqual(action["view_mode"], "form") + self.assertEqual(action["target"], "current") + + def test_visits_field_display(self): + """Test that visits field is accessible and editable.""" + self.assertEqual(self.blog_post.visits, 0) + # Update visits + self.blog_post.visits = 10 + self.assertEqual(self.blog_post.visits, 10) diff --git a/website_blog_usability/views/blog_post_views.xml b/website_blog_usability/views/blog_post_views.xml new file mode 100644 index 0000000000..0698006afb --- /dev/null +++ b/website_blog_usability/views/blog_post_views.xml @@ -0,0 +1,124 @@ + + + + + + blog.post.form.usability + blog.post + + + + + + + + + + + + + + + + + + + + + + + integer + 0 + + + + + + + blog.post.list.usability + blog.post + + + + + + + + + + + + + + +