Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
500 Visualizzazioni

``` python

# record.line_ids._ids = [1, 2, new_1, new_2], new_1, new_2 are some new records not saved yet

record.web_read({

    'line_ids': {

        'fields': {'name'}

    }

})

```


What I expect to get is a list of total 4 line_ids, with the new records.

But here I can only get 2 line_ids [1,2], not the new ones.


And this is because while read many2many fields, the `field.convert_to_read` only return `model.ids` not `model.\_ids`.


If I do `record.line_ids.web_read({'name': {}})`, it works fine, 4 line_ids are returned.

This is why it get me confused, same web_read call, but different result. It took me a whole afternoon to figure out why.


I understand that most of the time the convert_to_read should return model.ids, but is it possible to add a new parameter or a context value to make `convert_to_read` return `model.\_ids`? Or is there any other way to read records with many2many fields in a single call without worrying about the new records?

Avatar
Abbandona