Hi ricardo.wing,

You must override the 'name_get' function in the inherited python class. Its 
default behaviour is to return the value of the field whose name is defined by 
the '_rec_name' attribute, which in turn default to string value "name". Here 
are two examples:

Example 1
class inherited_partner(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'
    ...
    _columns = {
        'surname': fields.char(...),
        ...
    }
    _rec_name = 'surname'
inherited_partner()
This will display the value stored in field 'surname' instead of 'name'.

Example 2
class inherited_partner(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'
    ...
    _columns = {
        'surname': fields.char(...),
        ...
    }
    def name_get(self, cr, uid, ids, context=None):
        records = self.browse(cr, uid, ids)
        result = []
        for r in records:
            str = 'name'
            # If 'surname' not null
            if r.surname:
                str += ' (' + 
r.surname + ')'
            result.append((r.id, 
str))
        return result
inherited_partner()
This will display "name (surname)" instead of "name" if 'surname' is not null.




-------------------- m2f --------------------

--
http://www.openobject.com/forum/viewtopic.php?p=48012#48012

-------------------- m2f --------------------


_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users

Reply via email to