Odoo 16 Development Book

Manage website record

A website record is a record that contains everything on a website. Everything created or checked on the website's front end is stored on the website's back end. You can see all the details of your website stored in the backend. You can see how to create a form for your website and how to store this value in the backend.

Creates a menu used to store the selected product in the back end. To do this, you need to follow three basic steps

1. First, we need to create a menu called Repair Order.

<record id="menu_contactus" model="website.menu">
    <field name="name">My Product</field>
    <field name="url">/my_product</field>
    <field name="page_id" ref="website.contactus_page"/>
    <field name="parent_id" ref="website.main_menu"/>
    <field name="sequence" type="int">60</field>
 </record>

2. Then create a template that helps display the data when the menu is clicked.

<template id="my_product_temp" name="My Product">
    <t t-call="website.layout">
        <div id="wrap">
            <div class="oe_structure">
                <div class="container">
                    <form role="form" action="/create/my_product" method="POST">
                        <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
                        <div class="form-group">
                            <label for="product_id" class="control-label"> Product </label>
                            <select name="product_id" class="form-control link-style">
                                <t t-foreach="product_rec" t-as="product">
                                    <option t-esc="product.name" t-att-value="product.id"/>
                                </t>
                            </select>
                        </div>
                        <div class="clearfix oe_login_buttons">
                            <button type="submit" class="btn btn-primary pull-left">Submit</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </t>
 </template>

3. Create a controller to specify the actions

class Request(http.Controller):	
@http.route(['/my_product'], type='http', auth="public", website=True)
	def my_product(self, **kw):
    	product_rec = request.env['product.product'].sudo().search([])
    	    	return request.render("website_demo.my_product_temp", {
        	'product_rec': product_rec
        	})
	@http.route(['/create/myproduct'], type='http', auth="public", website=True)
	def create_my_product(self, **kw):
    	request.env['own.product'].sudo().create(kw)
    	return request.render("website_demo.submit_thank", {})
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message