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.

0

Is it possible to display custom data in the tree view?

v8
By
Kit Sunde
on 9/11/14, 4:35 PM 648 views

The email_template model has a field partner_to which is a comma separated char list of partners that will get emailed. I would like to display their names.

<tree string="Scheduled Emails">
  <field name="partner_to" eval="obj.partner_names()">
</tree>

But in my tree view it just displays the value of the field. If I change the name to a custom name it errors saying the field doesn't exist. What's the correct way of doing this?

2

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 9/12/14, 1:20 AM

You can create a function field that returns what you need and then include that field in the view.  So, in your case, first create the method:

def partner_names(self, cr, uid, ids, name, args, context=None)

    res = {}

    for _obj in self.browse(cr, uid, ids, context=None):

      res[_obj.id] = ....

    return res

Note that the signature of the method must be as I have described and the return value must be a dictionary whose key is each id that is being processed and the value is the value to return.

In the _columns, you add:

'partner_to_names': fields.function(partner_names, type='text', string='Partner Names')

Then use the field (partner_to_names) in the view.

Ah cool, that solved a separate search issue I was having too. Thanks.

Kit Sunde
on 9/12/14, 3:32 AM
0
Martin Pishpecki
On 2/17/15, 2:57 AM

Does anyone konw a way to create a generic tree and load it with custom data. Lets say we can make an empty grid and on load of a recors do a select and loat the grid with anything we want. Whith this I mean, doing this without creating a model for the data in the grid? Thx.

You should create a separate question if you want an answer to that, but you should be able to use a TransientModel.

Kit Sunde
on 2/17/15, 2:59 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: 9/11/14, 4:35 PM
Seen: 648 times
Last updated: 3/16/15, 8:10 AM