Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1908 Widoki

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 ?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
5
sty 20
4340
3
lip 25
22101
0
wrz 23
144
2
sty 24
16214
3
gru 17
11772