Update a one2many field

113 views
Skip to first unread message

Christophe (net)

unread,
Jun 2, 2015, 3:01:38 AM6/2/15
to try...@googlegroups.com
Hello

I try to update a value in a one2many through the on_change_* method.
I saw that it was possible to use the form:
{O2M: {'update': [{field: value, ...}]}}
but the latter does not update the records currently displayed in the
client and it is not possible to achieve in particular recording.
Is there a better way?

Regards
--
Christophe

Jean C

unread,
Jun 2, 2015, 3:09:01 AM6/2/15
to try...@googlegroups.com
Since the 3.4 version (I think), you do not have to return anything in on_change methods (NOT true
for on_change_with methods). Juste update the values of your field, and reset it to make sure it
is detected as modified :

def on_change_...(self):
    self.lines[0].name = 'some new name'
    # Force modification detection
    self.lines = self.lines

That's all !

Jean Cavallo
Coopengo

Christophe (net)

unread,
Jun 2, 2015, 3:12:58 AM6/2/15
to try...@googlegroups.com
Le 02/06/2015 09:08, Jean C a écrit :
>
> 2015-06-02 9:01 GMT+02:00 Christophe (net) <c...@adiczion.net
> <mailto:c...@adiczion.net>>:
Thank, but sorry i forgotten to precise, I'm on 3.0

--
Christophe
http://adiczion.com

Sergi Almacellas Abellana

unread,
Jun 2, 2015, 3:16:21 AM6/2/15
to try...@googlegroups.com
El 02/06/15 a les 09:12, Christophe (net) ha escrit:
You have to return the id in the dict values in order to the client know
which record you want to update. So it will be:

{O2M: {'update': [{'id': record_id, field: value, ...}]}}

Hope it helps!
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Christophe (net)

unread,
Jun 2, 2015, 3:20:20 AM6/2/15
to try...@googlegroups.com
It'works ! thanks.

--
Christophe

Josias Pérez

unread,
Sep 13, 2017, 2:50:06 AM9/13/17
to tryton
Could you give a complete example?

Sergi Almacellas Abellana

unread,
Sep 18, 2017, 4:06:17 AM9/18/17
to try...@googlegroups.com
El 13/09/17 a les 02:29, Josias Pérez ha escrit:
>> You have to return the id in the dict values in order to the client know
>> which record you want to update. So it will be:
>>
>> {O2M: {'update': [{'id': record_id, field: value, ...}]}}
>>
> Could you give a complete example?

It's difficult to provide a more complete example without the model
definition.

Could you explain what are you trying and what problems do you have?
Could you share your model definition?
Reply all
Reply to author
Forward
0 new messages