Odoo Help

Welcome!

This community 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.

1

Custom Model show on Website

By
Md. Tanzilul Hasan Khan
on 10/28/16, 2:06 PM 220 views

I have created a custom model, eg: custom.contact.addresses.

This model has tree view and form view. Each record of this model will be associated with each website.

How can I show this models value to website. Like - I can show:

website.field_name on qweb of website.

How to show custom.contact.address.field_name on website?        

1
shameem@aχoncoms
On 10/28/16, 10:57 PM

Hi Tanzil

You calculate the object from controller using "request" .

example

from openerp import http
from openerp.http import request

@http.route('/foo', type='http', website=True)
    def action_foo(self, **kw):
         bar = 1 # You calculate the id of object and assign. I gave 1 for example.
         obj = request.env['custom.contact.addresses'].search([('id', '=', bar)])
        return request.render('YourModule.YourTemplate', {'website':obj, })

You can use in template

     <t t-esc="website.field_name"/>

All the best !

In the custom model there is only one field called 'name'. No other field is there.

Should I create a many2one field for the website? How to let know the system the website_id?

Md. Tanzilul Hasan Khan
on 10/29/16, 8:51 AM

If your many2one field is

website_id = fields.Many2one('your.model, string='Website')

You can display

<t t-esc="website.website_id.name"/>

shameem@aχoncoms
on 10/31/16, 12:25 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/28/16, 2:06 PM
Seen: 220 times
Last updated: 10/31/16, 12:47 PM