Skip to Content
Menú
This question has been flagged
1 Respondre
1890 Vistes

Hi, i need to ask a question. We have a one2many field with name 'line_ids' in this form view.


When i click any record in this one2many field this form view appear. I need the access 'id' of record which i clicked in one2many field. I thought it will be in the context but apparently its not. active id and other params is related with main form view.

Any idea how can i get the id ?

Avatar
Descartar
Best Answer

Hi,

Use default_ context or pass the ID manually:

Access the One2many line's id directly in the form view:

When a record is opened in its form view , the record is passed by its own id , so you can access self.id directly in Python code (in the model or a form method).


@api.model

def some_method(self):

    _logger.info("This record ID: %s", self.id


So in any method (eg, @api.onchange , @api.model , etc.) within the child model , self.id is the correct ID of the record being edited or viewed.


i hope it is use full

Avatar
Descartar
Related Posts Respostes Vistes Activitat
5
de gen. 20
4308
3
de jul. 25
22061
0
de set. 23
144
2
de gen. 24
16176
3
de des. 17
11732