Skip to content

Commit 4916642

Browse files
committed
[ADD] website_attribute_set: add a module to show custom attributes in website
1 parent dc81e26 commit 4916642

15 files changed

Lines changed: 653 additions & 0 deletions

File tree

test-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
odoo-addon-attribute_set @ git+https://github.com/OCA/odoo-pim.git@refs/pull/192/head#subdirectory=attribute_set
2+
odoo-addon-product_attribute_set @ git+https://github.com/OCA/odoo-pim.git@refs/pull/196/head#subdirectory=product_attribute_set
3+
odoo-addon-pim @ git+https://github.com/OCA/odoo-pim.git@refs/pull/197/head#subdirectory=pim

website_attribute_set/README.rst

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
=====================
2+
Website Attribute Set
3+
=====================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:70a22a010d1706666b49f94906da9a8c7273649e03b5fce69b741553bebb3799
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%2Fodoo--pim-lightgray.png?logo=github
20+
:target: https://github.com/OCA/odoo-pim/tree/18.0/website_attribute_set
21+
:alt: OCA/odoo-pim
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/odoo-pim-18-0/odoo-pim-18-0-website_attribute_set
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/odoo-pim&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows the user to display and select custom attribute
32+
created by attribute_set module in website and e-commerce apps.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Usage
40+
=====
41+
42+
This module allows the user to display and select custom attribute
43+
created by attribute_set module in website and e-commerce apps.
44+
45+
Known issues / Roadmap
46+
======================
47+
48+
49+
50+
Bug Tracker
51+
===========
52+
53+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/odoo-pim/issues>`_.
54+
In case of trouble, please check there if your issue has already been reported.
55+
If you spotted it first, help us to smash it by providing a detailed and welcomed
56+
`feedback <https://github.com/OCA/odoo-pim/issues/new?body=module:%20website_attribute_set%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
57+
58+
Do not contact contributors directly about support or help with technical issues.
59+
60+
Credits
61+
=======
62+
63+
Authors
64+
-------
65+
66+
* Kencove
67+
68+
Contributors
69+
------------
70+
71+
- Mohamed Alkobrosli <[email protected]>
72+
73+
Maintainers
74+
-----------
75+
76+
This module is maintained by the OCA.
77+
78+
.. image:: https://odoo-community.org/logo.png
79+
:alt: Odoo Community Association
80+
:target: https://odoo-community.org
81+
82+
OCA, or the Odoo Community Association, is a nonprofit organization whose
83+
mission is to support the collaborative development of Odoo features and
84+
promote its widespread use.
85+
86+
.. |maintainer-kobros-tech| image:: https://github.com/kobros-tech.png?size=40px
87+
:target: https://github.com/kobros-tech
88+
:alt: kobros-tech
89+
90+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
91+
92+
|maintainer-kobros-tech|
93+
94+
This module is part of the `OCA/odoo-pim <https://github.com/OCA/odoo-pim/tree/18.0/website_attribute_set>`_ project on GitHub.
95+
96+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

website_attribute_set/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright 2011 Kencove (http://www.kencove.com).
2+
# @author Mohamed Alkobrosli <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
from . import models
6+
from . import controllers
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2011 Kencove (http://www.kencove.com).
2+
# @author Mohamed Alkobrosli <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
{
6+
"name": "Website Attribute Set",
7+
"version": "18.0.1.0.0",
8+
"category": "Website/Website",
9+
"license": "AGPL-3",
10+
"author": "Kencove, Odoo Community Association (OCA)",
11+
"maintainers": ["kobros-tech"],
12+
"website": "https://github.com/OCA/odoo-pim",
13+
"depends": [
14+
"attribute_set",
15+
"product_attribute_set",
16+
"pim",
17+
"website_sale",
18+
],
19+
"data": [],
20+
"installable": True,
21+
"application": True,
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2011 Kencove (http://www.kencove.com).
2+
# @author Mohamed Alkobrosli <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
from . import main
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2011 Kencove (http://www.kencove.com).
2+
# @author Mohamed Alkobrosli <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
from odoo.addons.website_sale.controllers import main
6+
7+
8+
class WebsiteSale(main.WebsiteSale):
9+
def shop(
10+
self,
11+
page=0,
12+
category=None,
13+
search="",
14+
min_price=0.0,
15+
max_price=0.0,
16+
ppg=False,
17+
**post,
18+
):
19+
rendered_templ = super().shop(
20+
page, category, search, min_price, max_price, ppg, **post
21+
)
22+
return rendered_templ
23+
24+
def _get_additional_shop_values(self, values):
25+
# Can be used to search & filter products depending on their custom attributes
26+
"""Hook to update values used for rendering website_sale.products template"""
27+
extra_values = super()._get_additional_shop_values(values)
28+
return extra_values
29+
30+
def product(self, product, category="", search="", **kwargs):
31+
rendered_templ = super().product(product, category, search, **kwargs)
32+
return rendered_templ
33+
34+
def _prepare_product_values(self, product, category, search, **kwargs):
35+
# If the product has a value for attribute_set_id
36+
# this will pass the attributes related to it's attribute_set_id
37+
# and then to be rendered in the website
38+
vals = super()._prepare_product_values(product, category, search, **kwargs)
39+
additional_attributes = product.get_extra_attributes()
40+
if additional_attributes:
41+
vals.update({"additional_attributes": additional_attributes})
42+
return vals
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2011 Kencove (http://www.kencove.com).
2+
# @author Mohamed Alkobrosli <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
from . import attribute_set_owner
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2011 Kencove (http://www.kencove.com).
2+
# @author Mohamed Alkobrosli <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
from odoo import models
6+
7+
8+
class AttributeSetOwnerMixin(models.AbstractModel):
9+
"""Mixin for consumers of attribute sets."""
10+
11+
_inherit = "attribute.set.owner.mixin"
12+
13+
def get_extra_attributes(self):
14+
"""Get extra product's attribute."""
15+
self.ensure_one()
16+
domain = [
17+
("model", "=", self._name),
18+
("attribute_set_ids", "!=", False),
19+
]
20+
if not self._context.get("include_native_attribute_view_ref"):
21+
domain.append(("nature", "=", "custom"))
22+
attribute = self.env["attribute.attribute"]
23+
if self.attribute_set_id:
24+
attributes = attribute.search(domain)
25+
attribute_set_id = self.attribute_set_id
26+
filtered_attributes = attributes.filtered(
27+
lambda rec: attribute_set_id.id in rec.attribute_set_ids.ids
28+
)
29+
return filtered_attributes
30+
else:
31+
return attribute
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Mohamed Alkobrosli \<<[email protected]>\>

0 commit comments

Comments
 (0)