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")```


  
4

1 回答 1

0

您不能将 track_visibility 用于 one2many 字段,而可以使用 message_post 方法。

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")```

于 2021-08-06T08:23:21.867 回答