odooodoo-9

method responsible for name in top view


enter image description here

I want to change the name that is colored in my picture. what method is responsible for its display? I tried with name_get but with no luck.


Solution

  • you should define a computed field and in the related function make your custom name with any logic that you want and for _rec_name use this computed field for example:

    class Test(models.Model):
    _name = "test"
    _description = 'test for custom rec name'
    _rec_name = 'record_name'
    
    t1 = fields.Char()
    t2 = fields.Char()
    record_name = fields.Char(compute="_set_record_name", store=False)
    def _set_record_name(self):
        for record in self:
            record.record_name = record.t1 + record.t2
    

    you can set anything you want to compute field