Skip to Content
Menu
This question has been flagged
1 Reply
2768 Views

hi all,

created 2 models Group and Category. 

Category contains a Many2one field which point to have id column of model Group

when I am running (in developer mode) Category form view (default generated by Odoo itself), it is showing pos.group,1  pos.group,2 instead of group_name

created view part for tree and form views, but still it is showing as mentioned above.

how I can show group_name in Many2one field? 

definitely I missed or did wrong something, please help resolving it.


what i did yet:


Model Group:

class PosGroup(models.Model):

    _name = "pos.group"

    _description = "Groups for POS"


    group_name = fields.Char(string='Group Name', required=True)


Model Category:

class PosCategory(models.Model):

    _name = "pos.category"

    _description = "Categories for POS"


    category_name = fields.Char(string='Category Name', required=True)

    group_id = fields.Many2one('pos.group', string='Related Group')


also please help, if a Model contains 2 columns as Many2one relationship, how it will be done if both fields reference a single/same Model? 

regards

Avatar
Discard

Either you can set rec_name for the model or define the name_get function for the model.

if you are new to odoo development, see this:

Rec name: https://www.youtube.com/watch?v=d_cyPsVc7vg

Name Get: https://www.youtube.com/watch?v=-1r3WSwtqxQ

Best Answer

Hi,

  Add _rec_name to your pos.group model

class PosGroup(models.Model):

    _name = "pos.group"

   _rec_name = 'group_name'

    _description = "Groups for POS"



Avatar
Discard
Related Posts Replies Views Activity
2
Apr 23
1451
2
May 24
35811
2
Nov 22
1478
1
Feb 22
6687
2
Dec 21
2706