0

Hi i want to set track_visibility for one2many fields by set : track_visibility='onchange' but it doesn't work.

This is my code:

class TransportManagement(models.Model):
    _name = 'transport.management'
    _inherit = ['mail.thread']
    _description = 'Transport Management'
  
 
   
    lines_info = fields.One2many('transport.management.lines', 'lines_id', string="Transport Informations") 


<!--second class-->

class TransportManagementLines(models.Model):

    
    _name = 'transport.management.lines'
    _description = 'Transport Management Lines'
    _rec_name = 'chauffeur'
    

    lines_id = fields.Many2one('transport.management',string="Crée Par")
    chauffeur = fields.Many2one('transport.management.matricule',string='Nom Chauffeur', required="1")```


  

1 Answers1

0

You cannot able to use track_visibility for one2many field, instead of you can use message_post method.

class TransportManagementLines(models.Model):
  
    _name = 'transport.management.lines'
    _description = 'Transport Management Lines'
    _rec_name = 'chauffeur'
    _inherit = ['mail.thread', 'ir.needaction_mixin']


         @api.model
         def create(self, vals):
                 res = super(Anything, self).create(vals)
                 if vals:
                    message = "Changes info"
                     res.lines_id.message_post(message)
                 return res
    

        lines_id = fields.Many2one('transport.management',string="Crée Par")
        chauffeur = fields.Many2one('transport.management.matricule',string='Nom Chauffeur',     required="1")```
Neural
  • 370
  • 1
  • 11