Skip to content

Commit 7158734

Browse files
committed
[ADD] website_product_quotation: add a new page in website
Add a new interactive page 'Product Quote' which shows predefined products. The goal of this commit was to create an interactive menu by implementing interaction framework to a bootstrap website. It also consist of some demo data that is needed for this page.
1 parent 6403263 commit 7158734

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1352
-0
lines changed

website_product_quotation/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import controllers
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Website Product Quotation",
3+
"category": "Website/Website",
4+
"description": "A website page to display set of products",
5+
"author": "Darpan",
6+
"depends": ["website", "website_sale", "crm"],
7+
"application": True,
8+
"installable": True,
9+
"auto_install": ["website"],
10+
"data": [
11+
"demo/product_attributes_demo.xml",
12+
"demo/product_demo.xml",
13+
"views/product_quote_template.xml",
14+
],
15+
"assets": {
16+
"web.assets_frontend": [
17+
"website_product_quotation/static/src/scss/product_quote_template.scss",
18+
"website_product_quotation/static/src/interactions/product_quote.js",
19+
]
20+
},
21+
"license": "AGPL-3",
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import product_quotation_controller
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from odoo import http
2+
from odoo.http import Controller, request
3+
4+
5+
class ProductQuotationController(Controller):
6+
@http.route("/product_quotation", type="http", auth="public", website=True)
7+
def show_page(self):
8+
product_names = [
9+
"Product A",
10+
"Product B",
11+
"Product C",
12+
"Product D",
13+
"Product E",
14+
"Product F",
15+
"Product G",
16+
"Product H",
17+
]
18+
19+
products = (
20+
request.env["product.template"]
21+
.sudo()
22+
.search([("name", "in", product_names)], limit=8)
23+
)
24+
25+
product_data = []
26+
website = request.website
27+
28+
for product in products:
29+
extra_images = (
30+
request.env["product.image"]
31+
.sudo()
32+
.search([("product_tmpl_id", "=", product.id)])
33+
)
34+
35+
extra_image_data = [
36+
{
37+
"url": website.image_url(img, "image_1024"),
38+
"name": img.name if img.name else "Untitled Image",
39+
}
40+
for img in extra_images
41+
]
42+
43+
product_data.append(
44+
{
45+
"id": product.id,
46+
"name": product.name,
47+
"image_url": website.image_url(product, "image_1024"),
48+
"extra_images": extra_image_data,
49+
"size": product.attribute_line_ids.filtered(
50+
lambda l: l.attribute_id.name == "SizeW"
51+
).mapped("value_ids.name"),
52+
"color": product.attribute_line_ids.filtered(
53+
lambda l: l.attribute_id.name == "Color"
54+
).mapped("value_ids.name"),
55+
"fabric": product.attribute_line_ids.filtered(
56+
lambda l: l.attribute_id.name == "Fabric"
57+
).mapped("value_ids.name"),
58+
"print": product.attribute_line_ids.filtered(
59+
lambda l: l.attribute_id.name == "Print"
60+
).mapped("value_ids.name"),
61+
"url": f"/shop/product/{product.id}",
62+
}
63+
)
64+
65+
return request.render(
66+
"website_product_quotation.product_quote_template",
67+
{"products": product_data},
68+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
4+
<!-- SizeW Attribute -->
5+
<record id="product_attribute_sizew" model="product.attribute">
6+
<field name="name">SizeW</field>
7+
</record>
8+
<record id="product_attribute_sizew_s" model="product.attribute.value">
9+
<field name="name">S</field>
10+
<field name="attribute_id" ref="product_attribute_sizew"/>
11+
</record>
12+
<record id="product_attribute_sizew_m" model="product.attribute.value">
13+
<field name="name">M</field>
14+
<field name="attribute_id" ref="product_attribute_sizew"/>
15+
</record>
16+
<record id="product_attribute_sizew_l" model="product.attribute.value">
17+
<field name="name">L</field>
18+
<field name="attribute_id" ref="product_attribute_sizew"/>
19+
</record>
20+
<record id="product_attribute_sizew_xl" model="product.attribute.value">
21+
<field name="name">XL</field>
22+
<field name="attribute_id" ref="product_attribute_sizew"/>
23+
</record>
24+
25+
<!-- Color Attribute -->
26+
<record id="product_attribute_color" model="product.attribute">
27+
<field name="name">Color</field>
28+
</record>
29+
<record id="product_attribute_color_white" model="product.attribute.value">
30+
<field name="name">White</field>
31+
<field name="attribute_id" ref="product_attribute_color"/>
32+
</record>
33+
<record id="product_attribute_color_black" model="product.attribute.value">
34+
<field name="name">Black</field>
35+
<field name="attribute_id" ref="product_attribute_color"/>
36+
</record>
37+
<record id="product_attribute_color_wood" model="product.attribute.value">
38+
<field name="name">Wood</field>
39+
<field name="attribute_id" ref="product_attribute_color"/>
40+
</record>
41+
42+
<!-- Fabric Attribute -->
43+
<record id="product_attribute_fabric" model="product.attribute">
44+
<field name="name">Fabric</field>
45+
</record>
46+
<record id="product_attribute_fabric_plastic" model="product.attribute.value">
47+
<field name="name">Plastic</field>
48+
<field name="attribute_id" ref="product_attribute_fabric"/>
49+
</record>
50+
<record id="product_attribute_fabric_leather" model="product.attribute.value">
51+
<field name="name">Leather</field>
52+
<field name="attribute_id" ref="product_attribute_fabric"/>
53+
</record>
54+
<record id="product_attribute_fabric_custom" model="product.attribute.value">
55+
<field name="name">Custom</field>
56+
<field name="attribute_id" ref="product_attribute_fabric"/>
57+
</record>
58+
59+
<!-- Print Attribute -->
60+
<record id="product_attribute_print" model="product.attribute">
61+
<field name="name">Print</field>
62+
</record>
63+
<record id="product_attribute_print_text" model="product.attribute.value">
64+
<field name="name">Text</field>
65+
<field name="attribute_id" ref="product_attribute_print"/>
66+
</record>
67+
<record id="product_attribute_print_graphics" model="product.attribute.value">
68+
<field name="name">Graphics</field>
69+
<field name="attribute_id" ref="product_attribute_print"/>
70+
</record>
71+
<record id="product_attribute_print_pattern" model="product.attribute.value">
72+
<field name="name">Pattern</field>
73+
<field name="attribute_id" ref="product_attribute_print"/>
74+
</record>
75+
<record id="product_attribute_print_solid" model="product.attribute.value">
76+
<field name="name">Solid</field>
77+
<field name="attribute_id" ref="product_attribute_print"/>
78+
</record>
79+
</odoo>

0 commit comments

Comments
 (0)