Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
6733 Ansichten

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?        

Avatar
Verwerfen
Beste Antwort

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 !

Avatar
Verwerfen
Autor

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?

If your many2one field is

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

You can display

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

Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Mai 17
5702
0
Jan. 25
1318
3
Dez. 19
8259
1
Juni 16
4376
16
Juni 16
19615