Skip to content

Commit 65dc0d5

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 65dc0d5

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

+1328
-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,44 @@
1+
from odoo import http
2+
from odoo.http import Controller, request
3+
4+
class ProductQuotationController(Controller):
5+
6+
@http.route("/product_quotation", type="http", auth="public", website=True)
7+
def show_page(self):
8+
product_names = ["Product A", "Product B", "Product C", "Product D", "Product E", "Product F", "Product G", "Product H"]
9+
10+
products = request.env['product.template'].sudo().search([
11+
('name', 'in', product_names)
12+
], limit=8)
13+
14+
product_data = []
15+
website = request.website
16+
17+
for product in products:
18+
extra_images = request.env['product.image'].sudo().search([
19+
('product_tmpl_id', '=', product.id)
20+
])
21+
22+
extra_image_data = [
23+
{
24+
"url": website.image_url(img, "image_1024"),
25+
"name": img.name if img.name else "Untitled Image",
26+
}
27+
for img in extra_images
28+
]
29+
30+
product_data.append({
31+
'id': product.id,
32+
'name': product.name,
33+
'image_url': website.image_url(product, "image_1024"),
34+
'extra_images': extra_image_data,
35+
'size': product.attribute_line_ids.filtered(lambda l: l.attribute_id.name == 'SizeW').mapped('value_ids.name'),
36+
'color': product.attribute_line_ids.filtered(lambda l: l.attribute_id.name == 'Color').mapped('value_ids.name'),
37+
'fabric': product.attribute_line_ids.filtered(lambda l: l.attribute_id.name == 'Fabric').mapped('value_ids.name'),
38+
'print': product.attribute_line_ids.filtered(lambda l: l.attribute_id.name == 'Print').mapped('value_ids.name'),
39+
'url': f"/shop/product/{product.id}",
40+
})
41+
42+
return request.render("website_product_quotation.product_quote_template", {
43+
'products': product_data
44+
})
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)