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

field in view not in class

v7
By
Oscar Cascante F
on 7/25/13, 2:46 PM 837 views

Hello,

I need to calculate a field in a view for display only, just for information. I mean, this field is just to display a sum in the view. There exists some way of putting a field in the view form, without reference it on the class.

Thanks.

0
Nishant Kashyap
On 7/25/13, 4:16 PM

You need to use functional field for this kind of requirement .

Example:

def _function(self, cr, uid, ids, field_name, field_value, arg, context=None):
        records = self.browse(cr, uid, ids)
        result = {}
        for r in records:
            str = ''
            if r.col1:
                str += r.col1
            if r.col2: 
               str += r.col2
            result[r.id] = str
        return result

_columns = {

    'col1': fields.char('Coloumn 1', size=5, required=True),
    'col2': fields.char('Coloumn 2', size=10, required=True),
    'col3': fields.function(_function, type='char', obj='basic.fldfunct', method=True, store=False, string='Column 3'),
                    }

In Views :

<field name="col1"/>
<field name="col2"/>
<field name="col3"/>

This is the simplest example of the Functional field.Hope this may help you.

Thanks for your answer. It seems that I do not explain correctly. In this example you have to declare the tree fields in the class ( columns = { ... ). My question was, there's any way to have a display field in a view without declare it in a class?

Oscar Cascante F
on 7/26/13, 1:00 AM

No, there is no such way in any framework I have work so far. Django,Ruby on Rails, Openerp7.

Nishant Kashyap
on 7/26/13, 4:01 AM

I really thanks the help that you have giving me. Maybe you could see my other post that have no answer yet, The post number 25533, thanks again.

Oscar Cascante F
on 7/26/13, 11:45 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

0 follower(s)

Stats

Asked: 7/25/13, 2:46 PM
Seen: 837 times
Last updated: 3/16/15, 8:10 AM