Skip to content

Commit c632545

Browse files
committed
[ADD] website_sale_dynamic_review_snippet: Module added
1 parent 4fe7223 commit c632545

34 files changed

+1467
-0
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
===================================
2+
Website Sale Dynamic Review Snippet
3+
===================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:d43413aa9ae52f19e0b4b115657a500479b34562b7628473e4cdc7c3007976b2
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github
20+
:target: https://github.com/OCA/e-commerce/tree/18.0/website_sale_dynamic_review_snippet
21+
:alt: OCA/e-commerce
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_dynamic_review_snippet
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
| This module provides a new website snippet that aggregates customer
32+
reviews from product templates.
33+
| It allows website administrators to display up to 100 reviews from one
34+
or more products in a single dynamic block, directly within the Odoo
35+
Website Builder.
36+
37+
| The snippet offers configuration options (maximum number of reviews)
38+
and renders reviews with rating stars, reviewer names, comments, and
39+
associated product names (if multiple products are chosen).
40+
| It is designed to be responsive and mobile-friendly, making it easy to
41+
showcase customer feedback on landing pages or promotional sections.
42+
43+
**Table of contents**
44+
45+
.. contents::
46+
:local:
47+
48+
Use Cases / Context
49+
===================
50+
51+
Business Need
52+
-------------
53+
54+
E-commerce websites often want to highlight customer feedback not only
55+
on individual product pages but also in centralized locations such as
56+
landing pages, category pages, or custom marketing sections.
57+
58+
By default, Odoo reviews are tied to specific products and cannot be
59+
easily aggregated or reused elsewhere on the website.
60+
61+
This module addresses this limitation by introducing a snippet that
62+
collects and displays multiple reviews in one place.
63+
64+
For example:
65+
66+
- A landing page showcasing testimonials from the most popular products.
67+
68+
- A category introduction page summarizing customer experiences.
69+
70+
- A homepage section displaying reviews from newly launched products.
71+
72+
Approach
73+
--------
74+
75+
The module extends the existing ``website_sale`` and ``website_rating``
76+
functionality to provide a configurable snippet.
77+
78+
The snippet fetches published reviews across selected products and
79+
displays them with a configurable limit (default 20, maximum 100).
80+
81+
Useful Information
82+
------------------
83+
84+
- **Dependencies:** Relies on ``website_sale`` and ``website_rating``.
85+
86+
- **Compatible modules:** Works well with marketing and promotional
87+
website features such as sliders, banners, or call-to-action snippets.
88+
89+
- **Suggested setups:** Useful in multi-website or multi-company
90+
scenarios where aggregated feedback should be highlighted across
91+
different contexts.
92+
93+
Usage
94+
=====
95+
96+
To use this module:
97+
98+
1. Go to the Website application.
99+
100+
2. Open the Website Builder (Edit → Add Blocks).
101+
102+
3. In the "Dynamic Snippets" section, drag and drop **Product Reviews
103+
Snippet** into your page.
104+
105+
|Insert Snippet|
106+
107+
4. Configure the snippet by adjusting the maximum number of reviews
108+
(default: 20, max: 100) and set two columns option.
109+
110+
|Configure Snippet|
111+
112+
5. Save your changes and publish the page.
113+
114+
The snippet will now display the aggregated reviews with rating
115+
stars, reviewer details, and comments.
116+
117+
|Rendered Snippet|
118+
119+
.. |Insert Snippet| image:: https://raw.githubusercontent.com/OCA/e-commerce/18.0/website_sale_dynamic_review_snippet/static/description/snippet_insert.png
120+
.. |Configure Snippet| image:: https://raw.githubusercontent.com/OCA/e-commerce/18.0/website_sale_dynamic_review_snippet/static/description/snippet_config.png
121+
.. |Rendered Snippet| image:: https://raw.githubusercontent.com/OCA/e-commerce/18.0/website_sale_dynamic_review_snippet/static/description/snippet_render.png
122+
123+
Bug Tracker
124+
===========
125+
126+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
127+
In case of trouble, please check there if your issue has already been reported.
128+
If you spotted it first, help us to smash it by providing a detailed and welcomed
129+
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_dynamic_review_snippet%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
130+
131+
Do not contact contributors directly about support or help with technical issues.
132+
133+
Credits
134+
=======
135+
136+
Authors
137+
-------
138+
139+
* XXP
140+
141+
Contributors
142+
------------
143+
144+
- `XXP <https://xxp-odoo.com>`__:
145+
146+
- Maksim Shurupov
147+
- Mike Lapin
148+
149+
Maintainers
150+
-----------
151+
152+
This module is maintained by the OCA.
153+
154+
.. image:: https://odoo-community.org/logo.png
155+
:alt: Odoo Community Association
156+
:target: https://odoo-community.org
157+
158+
OCA, or the Odoo Community Association, is a nonprofit organization whose
159+
mission is to support the collaborative development of Odoo features and
160+
promote its widespread use.
161+
162+
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/18.0/website_sale_dynamic_review_snippet>`_ project on GitHub.
163+
164+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import controllers
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "Website Sale Dynamic Review Snippet",
3+
"version": "18.0.1.0.0",
4+
"category": "Website",
5+
"depends": ["website_sale"],
6+
"summary": (
7+
"Aggregate website users’ reviews from product templates into a single "
8+
"website snippet (configurable, up to 100 records) "
9+
"accessible in the Odoo Website Builder."
10+
),
11+
"author": "XXP, Odoo Community Association (OCA)",
12+
"license": "AGPL-3",
13+
"website": "https://github.com/OCA/e-commerce",
14+
"data": [
15+
"views/snippets/options.xml",
16+
"views/snippets/s_dynamic_review.xml",
17+
],
18+
"assets": {
19+
"portal.assets_chatter": [
20+
"website_sale_dynamic_review_snippet/static/src/core/*",
21+
"website_sale_dynamic_review_snippet/static/src/components/*",
22+
"website_sale_dynamic_review_snippet/static/src/services/*",
23+
],
24+
"web.assets_frontend": [
25+
"website_sale_dynamic_review_snippet/static/src/boot/boot_service.esm.js",
26+
],
27+
"web.assets_tests": [
28+
"website_sale_dynamic_review_snippet/static/src/tests/*.esm.js"
29+
],
30+
},
31+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from odoo.http import Controller, request, route
2+
3+
from odoo.addons.mail.tools.discuss import Store
4+
5+
6+
class CustomerReview(Controller):
7+
@route(
8+
["/mail/review/messages"],
9+
methods=["POST"],
10+
type="json",
11+
auth="public",
12+
website=True,
13+
)
14+
def mail_review_messages(self, before=None, after=None, limit=30):
15+
domain = [
16+
("model", "=", "product.template"),
17+
("message_type", "=", "comment"),
18+
("rating_value", ">=", 1),
19+
]
20+
result = (
21+
request.env["mail.message"]
22+
.sudo()
23+
._message_fetch(domain, None, before, after, None, limit)
24+
)
25+
messages = result.pop("messages")
26+
messages_vals_list = messages.portal_message_format(
27+
options={"rating_include": True}
28+
)
29+
for vals in messages_vals_list:
30+
record = request.env[vals["model"]].sudo().browse(vals["res_id"])
31+
vals["thread"]["name"] = record.name
32+
vals["website_url"] = record.website_url
33+
return {
34+
**result,
35+
"data": {
36+
"mail.message": messages_vals_list,
37+
},
38+
"messages": Store.many_ids(messages),
39+
}
40+
41+
@route("/portal/review_init", type="json", auth="public", website=True)
42+
def portal_review_init(self, **kwargs):
43+
store = Store()
44+
request.env["res.users"]._init_store_data(store)
45+
if request.env.user.has_group("website.group_website_restricted_editor"):
46+
store.add(request.env.user.partner_id, {"is_user_publisher": True})
47+
products = request.env["product.template"].search([("is_published", "=", True)])
48+
product_obj = request.env["product.template"]
49+
for product in products:
50+
thread = product_obj._get_thread_with_access(product.id, **kwargs)
51+
if thread:
52+
mode = product_obj._get_mail_message_access([product.id], "create")
53+
has_react_access = product_obj._get_thread_with_access(
54+
product.id, mode, **kwargs
55+
)
56+
can_react = has_react_access
57+
store.add(
58+
thread,
59+
{
60+
"can_react": bool(can_react),
61+
"hasReadAccess": thread.sudo(False).has_access("read"),
62+
},
63+
as_thread=True,
64+
)
65+
return store.get_result()
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * website_sale_dynamic_review_snippet
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 18.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2025-09-11 23:17+0000\n"
10+
"PO-Revision-Date: 2025-09-11 23:17+0000\n"
11+
"Last-Translator: AI Assistant\n"
12+
"Language-Team: Russian\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: website_sale_dynamic_review_snippet
19+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.s_dynamic_review_options
20+
msgid "100"
21+
msgstr "100"
22+
23+
#. module: website_sale_dynamic_review_snippet
24+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.s_dynamic_review_options
25+
msgid "20"
26+
msgstr "20"
27+
28+
#. module: website_sale_dynamic_review_snippet
29+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.s_dynamic_review_options
30+
msgid "40"
31+
msgstr "40"
32+
33+
#. module: website_sale_dynamic_review_snippet
34+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.s_dynamic_review_options
35+
msgid "60"
36+
msgstr "60"
37+
38+
#. module: website_sale_dynamic_review_snippet
39+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.s_dynamic_review_options
40+
msgid "80"
41+
msgstr "80"
42+
43+
#. module: website_sale_dynamic_review_snippet
44+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.s_dynamic_review_snippet
45+
msgid "Customer Reviews"
46+
msgstr "Отзывы клиентов"
47+
48+
#. module: website_sale_dynamic_review_snippet
49+
#. odoo-javascript
50+
#: code:addons/website_sale_dynamic_review_snippet/static/src/components/message_review_list.xml:0
51+
msgid "Load More"
52+
msgstr "Загрузить еще"
53+
54+
#. module: website_sale_dynamic_review_snippet
55+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.s_dynamic_review_options
56+
msgid "Max Number of Reviews"
57+
msgstr "Максимальное количество отзывов"
58+
59+
#. module: website_sale_dynamic_review_snippet
60+
#. odoo-javascript
61+
#: code:addons/website_sale_dynamic_review_snippet/static/src/components/message_review_list.esm.js:0
62+
msgid "No messages found"
63+
msgstr "Сообщения не найдены"
64+
65+
#. module: website_sale_dynamic_review_snippet
66+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.snippets
67+
msgid "Product Reviews Snippet"
68+
msgstr "Сниппет отзывов о товарах"
69+
70+
#. module: website_sale_dynamic_review_snippet
71+
#. odoo-javascript
72+
#: code:addons/website_sale_dynamic_review_snippet/static/src/components/message_review_list.xml:0
73+
msgid "There are no reviews"
74+
msgstr "Отзывов нет"
75+
76+
#. module: website_sale_dynamic_review_snippet
77+
#: model_terms:ir.ui.view,arch_db:website_sale_dynamic_review_snippet.s_dynamic_review_options
78+
msgid "Two Columns"
79+
msgstr "Две колонки"

0 commit comments

Comments
 (0)