Odoo Help

0

how we render model form in controller in odoo v9

By
kartik
on 1/22/16, 7:48 AM 1,151 views

hi,

i created one module in odoo v9 ,i created model for that now i want to serve this form in website with appropriate route so how can i do that in odoo.

i tried that create one controller with route and in template i added form 

my controller.py is like


@http.route('/change_mod/new/', website=True)

def add_model(self):

return request.render('change_address_model.add_model')


my view.xml is like


<record id="change_address_model_form" model="ir.ui.view">

<field name="name">change.address.model.form</field>

<field name="model">consulate.changeaddressmodel</field>

<field name="arch" type="xml">

<form string="ChangeAddressModel" version="9.0">

<group col="2">

<field name="partner_id" />

<field name="old_address" />

<field name="home_tel" />

</group>

</form>

</field>

</record>

<record id="change_of_address_model_tree" model="ir.ui.view">

<field name="name">change.address.model.tree</field>

<field name="model">consulate.changeaddressmodel</field>

<field name="arch" type="xml">

<tree string="ChangeAddressModel">

<field name="partner_id" />

<field name="old_address" />

<field name="home_tel" />

</tree>

</field>

</record>

<record model="ir.actions.act_window" id="action_change_of_address_model">

<field name="name">Change of Address Model Form</field>

<field name="type">ir.actions.act_window</field>

<field name="res_model">consulate.changeaddressmodel</field>

<field name="view_type">form</field>

<field name="view_mode">tree,form</field>

<field name="view_id" ref="change_of_address_tree"/>

<field name="help" type="html">

<p class="oe_view_nocontent_create">

Click here to create a Change of Address Model Form.

</p>

</field>

</record>

<record model="ir.ui.view" id="change_of_address_search">

<field name="name">change.of.address.model.search</field>

<field name="model">consulate.changeaddressmodel</field>

<field name="arch" type="xml">

<search string="Change of Address Model">

<field name="partner_id" />

<field name="old_address" />

<field name="home_tel" />

<!--<t t-if="partner_id.name"><field name="partner_id.name" /></t>-->

</search>

</field>

</record>


after thta when i go to that route so it not render form properly in odoo

so how can i do that in odoo

please help,

thanks in advance





0

 You cannot add view in a template. Template itself are the rendering element used to display data on the website page. Try looking at the website_sale module to get more idea about templates.

hi, Thanks for your response. i have gone through website_sale module try to render the form but it was not working. can you please specify in more detail which portion of code of website_sale module is used for rendering element on website page . please note : I am trying to render odoo model form in website page not in odoo admin dashboard please help me in that

kartik
on 2/1/16, 1:36 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/22/16, 7:48 AM
Seen: 1151 times
Last updated: 1/22/16, 12:17 PM