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

How the display custom field value instead of name in many2one Odoo 8

By
Silviaa
on 11/4/16, 7:19 AM 149 views

I have custom field named as 'code'  in res.partner

        class cust_partner

         _inherit = 'res.partner'

         _columns = { 'code': fields.char('Code', index=True), }

Customized name_get , name_search methods to get code instead of Customer name

it works only in Search and display name in field


In my custom class

        class test_order(osv.Model):
        _inherit = 'test_order'_columns = {   'customer_code': fields.many2one('res.partner', 'Code', ondelete='restrict',required=False),}

My expected output is in test_order class i need to display value of  'code' instead of name in field customer_code (after save in form view )

Please anyone help me to resolve this








0
fasluca
On 11/4/16, 7:26 AM

Use name_get() and name_search() method
or use "_rec_name = 'code'"

class cust_partner
_inherit = 'res.partner'
_rec_name = 'code'
_columns = {
       'code': fields.char('Code', index=True),
        }


yes used name_get , name_search it works only in field list , search value not after save

I need to display the code value in Form View (i.e) after save

Silviaa
on 11/4/16, 7:34 AM

_rec_name = 'code' doesnt work for me

Silviaa
on 11/4/16, 9:06 AM

could you share your name search and name get functions?

fasluca
on 11/4/16, 11:15 PM

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: 11/4/16, 7:19 AM
Seen: 149 times
Last updated: 11/4/16, 7:46 AM