Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

17.0 mig website sale product assortment #1

Open
wants to merge 89 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
2c35e62
Initialize 17.0 branch
OCA-git-bot Nov 12, 2023
fe06481
[10.0] website_sale_hide_price: New module
chienandalu Aug 8, 2017
f00c2ef
OCA Transbot updated translations from Transifex
oca-transbot Dec 16, 2017
350c33f
[MIG] website_sale_hide_price: Migration to 11.0
AbrahamTrey Jun 13, 2018
551ccc2
Translated using Weblate (Persian)
fshahy Jul 21, 2018
0859f56
Translated using Weblate (German)
Aug 27, 2018
1bbcaca
[FIX][11.0][website_sale_hide_price] Disable Add to cart option to pr…
JuanjoA Oct 11, 2018
5f06860
[FIX] web_sale_hide_price: fix error with product comparison tool
maitaoriana Mar 7, 2019
b55ee42
Translated using Weblate (Italian)
paolovalier Dec 28, 2018
e344463
[MIG] website_sale_hide_price: Migration to 12.0
bouvyd Oct 29, 2018
6bdacd8
[MIG] website_sale_hide_price: Migration to 12.0
maitaoriana Feb 19, 2020
0eb493b
[REF] website_sale_hide_price: known issues added to README
maitaoriana Feb 19, 2020
4d91925
Translated using Weblate (German)
AndreVolksdorf Aug 11, 2020
bcb1f6f
Translated using Weblate (Slovenian)
sysadminmatmoz Aug 11, 2020
60040bb
[IMP] website_sale_hide_price: black, isort, prettier
maitaoriana Oct 20, 2020
4805cd0
[MIG] website_sale_hide_price: Migration to 13.0
maitaoriana Oct 20, 2020
e8093e5
[FIX] website_sale_hide_price: validate website exist in search box view
maitaoriana Oct 28, 2020
63654d4
[FIX] website_sale_hide_price: wrong template inheritance
wtaferner Dec 5, 2020
208ae56
Translated using Weblate (Catalan)
claudiagn Feb 25, 2021
c636087
Translated using Weblate (Spanish)
claudiagn Feb 25, 2021
290fe62
[MIG] website_sale_hide_price: Migration to 14.0
May 18, 2021
bc9d21d
Translated using Weblate (Spanish (Argentina))
ibuioli Sep 11, 2021
d3e2aac
[IMP] website_sale_hide_price: hide price at product level
chienandalu May 13, 2022
73f0ac1
[IMP] website_sale_comparison_hide_price: hide price at product level
chienandalu May 13, 2022
3f6bb5c
[MIG] website_sale_hide_price: Migration to 15.0
CarlosRoca13 Jun 2, 2022
baac265
[UPD] Update website_sale_hide_price.pot
Jun 13, 2022
4bd8554
[UPD] README.rst
OCA-git-bot Jun 13, 2022
4191eaf
[MIG] website_sale_hide_price: Migration to 16.0
JrAdhoc Dec 16, 2022
cd78bb1
[UPD] Update website_sale_hide_price.pot
Dec 28, 2022
4b3d25a
[UPD] README.rst
OCA-git-bot Dec 28, 2022
0db7037
Update translation files
weblate Dec 28, 2022
33c79b1
Translated using Weblate (Italian)
mymage Dec 28, 2022
65be454
Translated using Weblate (Italian)
francesco-ooops Feb 1, 2023
8ac1b0e
Translated using Weblate (Spanish (Argentina))
ibuioli Mar 12, 2023
967655b
Added translation using Weblate (Portuguese)
pedrocs-exo Mar 29, 2023
96b829f
Translated using Weblate (Portuguese)
pedrocs-exo Mar 29, 2023
1284015
fix error show badge_extra_price
manuelcalerosolis May 31, 2023
792cf15
[FIX] website_sale_hide_price: fix key error when editing snippet
pilarvargas-tecnativa May 26, 2023
eb032f8
[IMP] website_sale_hide_price: Hide add to cart button and prices
pilarvargas-tecnativa May 29, 2023
156e7d0
website_sale_hide_price 16.0.1.1.0
OCA-git-bot Jun 1, 2023
40b6217
website_sale_hide_price 16.0.1.2.0
OCA-git-bot Jun 1, 2023
eb44ce4
[FIX] website_sale_hide_price: hide the price in the add_to_cart option
pilarvargas-tecnativa Mar 1, 2023
6b114a1
[15.0][FIX] website_sale_hide_price, hide price on results of search bar
ChrisOForgeFlow Mar 14, 2023
39281be
[UPD] README.rst
OCA-git-bot Jun 1, 2023
d4fbab4
website_sale_hide_price 16.0.1.2.1
OCA-git-bot Jun 1, 2023
7285793
Translated using Weblate (German)
NICO-SOLUTIONS Jul 8, 2023
bfb9e62
Translated using Weblate (Spanish)
Ivorra78 Aug 3, 2023
723dc96
[FIX] website_sale_hide_price: display price in search bar
remi-filament Jul 11, 2023
0f18ddb
website_sale_hide_price 16.0.1.3.0
OCA-git-bot Aug 17, 2023
727c0c7
[UPD] README.rst
OCA-git-bot Sep 3, 2023
779eba0
Translated using Weblate (Japanese)
rinaldifirdaus Sep 15, 2023
b4fd447
Update translation files
weblate Oct 9, 2023
888ee45
[16.0][FIX] website_sale_hide_price: Error loading view after update
Nov 8, 2023
e108972
[BOT] post-merge updates
OCA-git-bot Nov 8, 2023
e62bbd2
[IMP] website_sale_hide_price: hide prices at website level
amkarthik Dec 27, 2023
27ff609
[UPD] Update website_sale_hide_price.pot
Jan 8, 2024
8800621
[BOT] post-merge updates
OCA-git-bot Jan 8, 2024
86a6a4f
Update translation files
weblate Jan 8, 2024
e8b9150
Translated using Weblate (Spanish)
Ivorra78 Jan 9, 2024
fa66e00
Translated using Weblate (Spanish (Argentina))
ibuioli Jan 17, 2024
0a5f0d8
[MIG] website_sale_hide_price: Migration to 17.0
sylvainvh Mar 27, 2024
20eb1ff
[UPD] Update website_sale_hide_price.pot
Apr 15, 2024
8adcc61
[BOT] post-merge updates
OCA-git-bot Apr 15, 2024
d40b0c0
Update translation files
weblate Apr 15, 2024
eef41c9
Translated using Weblate (Italian)
mymage Apr 16, 2024
2260e74
Translated using Weblate (Italian)
scigghia Apr 16, 2024
eafab35
[IMP] update dotfiles
OCA-git-bot May 1, 2024
f394394
Translated using Weblate (Swedish)
jakobkrabbe Jun 5, 2024
93eac0c
[17.0][FIX] website_sale_hide_price: qweb cache
stanislaw-ladorucki May 5, 2024
d0cd174
[BOT] post-merge updates
OCA-git-bot Jun 20, 2024
e02a9b2
[IMP] Update copier template
pedrobaeza Jun 24, 2024
60d7fde
[IMP] update dotfiles
OCA-git-bot Jul 6, 2024
b6e1e84
[ADD] website_sale_product_assortment: New module to use product asso…
CarlosRoca13 Nov 29, 2021
904203b
[FIX] website_sale_product_assortment: 'set' object does not support …
carlosdauden Dec 28, 2021
7b62d8f
[FIX] website_sale_product_assortment: Error when no variant_ids in t…
CarlosRoca13 Jan 20, 2022
8cd9cae
[ADD] icon.png
OCA-git-bot Jun 28, 2022
ed82a67
[IMP] website_sale_product_assortment: black, isort, prettier
AshishHirapara Jul 1, 2022
97028b1
[MIG] website_sale_product_assortment: Migration to 14.0
AshishHirapara Jul 1, 2022
c010a60
[UPD] README.rst
OCA-git-bot Jul 4, 2022
9f8ac8b
Added translation using Weblate (Italian)
francesco-ooops Jul 5, 2022
723a08f
Translated using Weblate (Italian)
francesco-ooops Jul 5, 2022
1149d60
[MIG] website_sale_product_assortment: Migration to 15.0
stefan-tecnativa Feb 7, 2023
b6cc7a2
Update translation files
weblate Feb 9, 2023
4d5a283
Translated using Weblate (Italian)
mymage Jun 13, 2023
9b96acb
Translated using Weblate (Spanish)
Ivorra78 Jul 5, 2023
e13032a
[MIG] website_sale_product_assortment: Migration to version 16.0
pilarvargas-tecnativa Nov 10, 2023
f539723
[UPD] Update website_sale_product_assortment.pot
Nov 21, 2023
dfaf4b9
[IMP] website_sale_product_assortment: pre-commit auto fixes
PieterPaulussen Jul 19, 2024
7254405
[MIG] website_sale_product_assortment: Migration to 17.0
PieterPaulussen Jul 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ env:

# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
parserOptions:
ecmaVersion: 2022
ecmaVersion: 2020
sourceType: module

overrides:
- files:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Available addons
addon | version | maintainers | summary
--- | --- | --- | ---
[website_sale_hide_price](website_sale_hide_price/) | 17.0.1.1.0 | | Hide product prices on the shop
[website_sale_suggest_create_account](website_sale_suggest_create_account/) | 17.0.1.0.0 | | Suggest users to create an account when buying in the website

[//]: # (end addons)

Expand Down
3 changes: 1 addition & 2 deletions setup/_metapackage/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[project]
name = "odoo-addons-oca-e-commerce"
version = "17.0.20240726.0"
version = "17.0.20240415.0"
dependencies = [
"odoo-addon-website_sale_hide_price>=17.0dev,<17.1dev",
"odoo-addon-website_sale_suggest_create_account>=17.0dev,<17.1dev",
]
classifiers=[
"Programming Language :: Python",
Expand Down
113 changes: 113 additions & 0 deletions website_sale_product_assortment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
============================
eCommerce product assortment
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2d8807010bb9fc649f45e174777ff7e9dd0d2843032901734194c53123809266
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/17.0/website_sale_product_assortment
:alt: OCA/e-commerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-commerce-17-0/e-commerce-17-0-website_sale_product_assortment
: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/e-commerce&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to set e-commerce restrictions on product
assortments.

**Table of contents**

.. contents::
:local:

Configuration
=============

To see this module working, you have to define a product assortment and
select an option on the website availability field.

#. **Don't apply restriction**: This option will not set any kind of
restriction on product items. #. **Avoid to show non available
products**: This option will hide on the e-commerce, the products that
are not added to the products domain. If a product template has at least
one allowed variant to show, the product will appear on the product
items view but only that variants will be able to be bought. #. **Avoid
selling not available products**: This option will restrict to buy the
products that are added to the assortment on the e-commerce. To inform
the clients, two more fields were added: "Message when unavailable" and
"Assortment information". The first one will add a short description to
the product item and the other one will set a detailed description on
the product sheet. This second one is editable from the website editor.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/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 <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_product_assortment%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Carlos Roca
- Pedro M. Baeza
- Stefan Ungureanu
- Pilar Vargas

- `Ooops <https://www.ooops404.com>`__:

- Ashish Hirpara (https://ashish-hirpara.com)

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-CarlosRoca13| image:: https://github.com/CarlosRoca13.png?size=40px
:target: https://github.com/CarlosRoca13
:alt: CarlosRoca13

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-CarlosRoca13|

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/17.0/website_sale_product_assortment>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions website_sale_product_assortment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
28 changes: 28 additions & 0 deletions website_sale_product_assortment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2021 Tecnativa - Carlos Roca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "eCommerce product assortment",
"summary": "Use product assortments to display products available on e-commerce.",
"version": "17.0.1.0.0",
"development_status": "Beta",
"license": "AGPL-3",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["CarlosRoca13"],
"installable": True,
"depends": ["product_assortment", "website_sale"],
"data": ["views/ir_filters_views.xml"],
"assets": {
"web.assets_frontend": [
"website_sale_product_assortment/static/src/xml/*.xml",
"website_sale_product_assortment/static/src/js/variant_mixin.js",
"website_sale_product_assortment/static/src/js/assortment_list_preview.js",
],
"web.assets_tests": [
"website_sale_product_assortment/static/src/js/no_purchase_tour.js",
"website_sale_product_assortment/static/src/js/no_restriction_tour.js",
"website_sale_product_assortment/static/src/js/no_show_tour.js",
],
},
}
2 changes: 2 additions & 0 deletions website_sale_product_assortment/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import variant
from . import website_sale
42 changes: 42 additions & 0 deletions website_sale_product_assortment/controllers/variant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2020 Tecnativa - Carlos Roca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, http
from odoo.http import request

from odoo.addons.website_sale.controllers.variant import WebsiteSaleVariantController


class WebsiteSaleVariantControllerAssortment(WebsiteSaleVariantController):
@http.route(
["/sale/get_info_assortment_preview"],
type="json",
auth="public",
methods=["POST"],
website=True,
)
def get_info_assortment_preview(self, product_template_ids, **kw):
"""Special route to use website logic in get_combination_info override.
This route is called in JS by appending _website to the base route.
"""
res = []
templates = request.env["product.template"].sudo().browse(product_template_ids)
not_allowed_product_dict = templates.get_product_assortment_restriction_info(
templates.mapped("product_variant_ids.id")
)
for template in templates:
variant_ids = set(template.product_variant_ids.ids)
if (
variant_ids
and variant_ids & set(not_allowed_product_dict.keys()) == variant_ids
):
res.append(
{
"id": template.id,
"message_unavailable": not_allowed_product_dict[
variant_ids.pop()
][0].message_unavailable
or _("Not available"),
}
)
return res
109 changes: 109 additions & 0 deletions website_sale_product_assortment/controllers/website_sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright 2021 Tecnativa - Carlos Roca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from werkzeug.exceptions import NotFound

from odoo.http import request, route

from odoo.addons.website.controllers.main import Website
from odoo.addons.website_sale.controllers.main import WebsiteSale


class WebsiteSaleAssortment(WebsiteSale):
def _get_products_allowed(self):
partner = request.env.user.partner_id
website_id = request.website.id
assortments = (
request.env["ir.filters"]
.sudo()
.search(
[
("is_assortment", "=", True),
("website_availability", "=", "no_show"),
"|",
("website_ids", "=", False),
("website_ids", "=", website_id),
]
)
)
assortment_restriction = False
allowed_product_ids = set()
for assortment in assortments:
if (
# Set active_test to False to allow filtering by partners
# that are not active, (for example Public User)
partner & assortment.with_context(active_test=False).all_partner_ids
):
assortment_restriction = True
allowed_product_ids = allowed_product_ids.union(
set(assortment.all_product_ids.ids)
)
return allowed_product_ids, assortment_restriction

@route()
def product(self, product, category="", search="", **kwargs):
"""Overriding product method to avoid accessing to product sheet when the
product assortments prevent to show them.
"""
allowed_product_ids, assortment_restriction = self._get_products_allowed()
if assortment_restriction:
if len(set(product.product_variant_ids.ids) & allowed_product_ids) == 0:
raise NotFound()
return super().product(product, category=category, search=search, **kwargs)

def _get_search_options(
self,
category=None,
attrib_values=None,
pricelist=None,
min_price=0.0,
max_price=0.0,
conversion_rate=1,
**post,
):
"""Overriding _get_search_options method to avoid show product templates that
has all their variants not allowed to be shown."""
res = super()._get_search_options(
category=category,
attrib_values=attrib_values,
pricelist=pricelist,
min_price=min_price,
max_price=max_price,
conversion_rate=conversion_rate,
**post,
)
allowed_product_ids, assortment_restriction = self._get_products_allowed()
if assortment_restriction:
res["allowed_product_domain"] = [
("product_variant_ids", "in", list(allowed_product_ids))
]
return res


class WebsiteAssortment(Website):
@route()
def autocomplete(
self,
search_type=None,
term=None,
order=None,
limit=5,
max_nb_chars=999,
options=None,
):
(
allowed_product_ids,
assortment_restriction,
) = WebsiteSaleAssortment._get_products_allowed(self)
if assortment_restriction:
options["allowed_product_domain"] = [
("product_variant_ids", "in", list(allowed_product_ids))
]

return super().autocomplete(
search_type=search_type,
term=term,
order=order,
limit=limit,
max_nb_chars=max_nb_chars,
options=options,
)
Loading