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

Master website product quotation dtda #651

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions website_product_quotation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import controllers
22 changes: 22 additions & 0 deletions website_product_quotation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Website Product Quotation",
'category': 'Website/Website',
"description": "A website page to display set of products",
"author": "Darpan",
"depends": ["website","website_sale","crm"],
"application": True,
"installable": True,
"auto_install": ["website"],
"data": [
"demo/product_attributes_demo.xml",
"demo/product_demo.xml",
"views/product_quote_template.xml"
],
"assets": {
"web.assets_frontend":[
"website_product_quotation/static/src/scss/product_quote_template.scss",
"website_product_quotation/static/src/interactions/product_quote.js"
]
},
"license": "AGPL-3"
}
1 change: 1 addition & 0 deletions website_product_quotation/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_quotation_controller
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from odoo import http
from odoo.http import Controller, request

class ProductQuotationController(Controller):

@http.route("/product_quotation", type="http", auth="public", website=True)
def show_page(self):
product_names = ["Product A", "Product B", "Product C", "Product D", "Product E", "Product F", "Product G", "Product H"]

products = request.env['product.template'].sudo().search([
('name', 'in', product_names)
], limit=8)

product_data = []
website = request.website

for product in products:
extra_images = request.env['product.image'].sudo().search([
('product_tmpl_id', '=', product.id)
])

extra_image_data = [
{
"url": website.image_url(img, "image_1024"),
"name": img.name if img.name else "Untitled Image",
}
for img in extra_images
]

product_data.append({
'id': product.id,
'name': product.name,
'image_url': website.image_url(product, "image_1024"),
'extra_images': extra_image_data,
'size': product.attribute_line_ids.filtered(lambda l: l.attribute_id.name == 'SizeW').mapped('value_ids.name'),
'color': product.attribute_line_ids.filtered(lambda l: l.attribute_id.name == 'Color').mapped('value_ids.name'),
'fabric': product.attribute_line_ids.filtered(lambda l: l.attribute_id.name == 'Fabric').mapped('value_ids.name'),
'print': product.attribute_line_ids.filtered(lambda l: l.attribute_id.name == 'Print').mapped('value_ids.name'),
'url': f"/shop/product/{product.id}",
})

return request.render("website_product_quotation.product_quote_template", {
'products': product_data
})
79 changes: 79 additions & 0 deletions website_product_quotation/demo/product_attributes_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<!-- SizeW Attribute -->
<record id="product_attribute_sizew" model="product.attribute">
<field name="name">SizeW</field>
</record>
<record id="product_attribute_sizew_s" model="product.attribute.value">
<field name="name">S</field>
<field name="attribute_id" ref="product_attribute_sizew"/>
</record>
<record id="product_attribute_sizew_m" model="product.attribute.value">
<field name="name">M</field>
<field name="attribute_id" ref="product_attribute_sizew"/>
</record>
<record id="product_attribute_sizew_l" model="product.attribute.value">
<field name="name">L</field>
<field name="attribute_id" ref="product_attribute_sizew"/>
</record>
<record id="product_attribute_sizew_xl" model="product.attribute.value">
<field name="name">XL</field>
<field name="attribute_id" ref="product_attribute_sizew"/>
</record>

<!-- Color Attribute -->
<record id="product_attribute_color" model="product.attribute">
<field name="name">Color</field>
</record>
<record id="product_attribute_color_white" model="product.attribute.value">
<field name="name">White</field>
<field name="attribute_id" ref="product_attribute_color"/>
</record>
<record id="product_attribute_color_black" model="product.attribute.value">
<field name="name">Black</field>
<field name="attribute_id" ref="product_attribute_color"/>
</record>
<record id="product_attribute_color_wood" model="product.attribute.value">
<field name="name">Wood</field>
<field name="attribute_id" ref="product_attribute_color"/>
</record>

<!-- Fabric Attribute -->
<record id="product_attribute_fabric" model="product.attribute">
<field name="name">Fabric</field>
</record>
<record id="product_attribute_fabric_plastic" model="product.attribute.value">
<field name="name">Plastic</field>
<field name="attribute_id" ref="product_attribute_fabric"/>
</record>
<record id="product_attribute_fabric_leather" model="product.attribute.value">
<field name="name">Leather</field>
<field name="attribute_id" ref="product_attribute_fabric"/>
</record>
<record id="product_attribute_fabric_custom" model="product.attribute.value">
<field name="name">Custom</field>
<field name="attribute_id" ref="product_attribute_fabric"/>
</record>

<!-- Print Attribute -->
<record id="product_attribute_print" model="product.attribute">
<field name="name">Print</field>
</record>
<record id="product_attribute_print_text" model="product.attribute.value">
<field name="name">Text</field>
<field name="attribute_id" ref="product_attribute_print"/>
</record>
<record id="product_attribute_print_graphics" model="product.attribute.value">
<field name="name">Graphics</field>
<field name="attribute_id" ref="product_attribute_print"/>
</record>
<record id="product_attribute_print_pattern" model="product.attribute.value">
<field name="name">Pattern</field>
<field name="attribute_id" ref="product_attribute_print"/>
</record>
<record id="product_attribute_print_solid" model="product.attribute.value">
<field name="name">Solid</field>
<field name="attribute_id" ref="product_attribute_print"/>
</record>
</odoo>
Loading