Technical mailing list archives


Re: Some help please - onchange

Open For Small Business Ltd, Graeme Gellatly
- 20/03/2017 20:04:10
Nope, thats not it. 

Tried that and get a log warning that onchange needs to be a valid field name whenever using dotted notation.

To date everything but editing the existing assigned m2o works. 

If you change record, works as expected. 
If you create record works as expected. 
If you edit an existing record the return value is as expected and the warning message as well.

In fact these 3 actions give identical onchange return values and all display the stock warning.  If I trace it all the way through to the json response it is still as expected.

My guess is that there is something on the js side saying do not update as nothing has changed.

If I add a boolean field and use that to trigger the onchange to update from the modified record it works but its real clumsy with the losing of focus etc so not a workable solution.  Sucks as it worked so nicely under the old api.  There must be some way of signalling the client to use the returned response.

On Tue, Mar 21, 2017 at 1:05 AM, Pedro Manuel Baeza Romero <> wrote:
Hi, Graeme,

You have to add subfields in the onchange:

@api.onchange('custom_id', 'custom_id.o2m_field', 'custom_id.o2m_field.qty')
def custom_id_change(self):


2017-03-20 5:50 GMT+01:00 Graeme Gellatly <>:

I have the following design in v10 that I just can't get working right.

Sale Order -> Sale Order Line (o2m standard sale module)
Sale Order Line -> Custom Model (m2o on editable so line)
Custom Model -> Custom Model Lines (o2m)

  • The forms are all standard, with the addition of custom model m2o on the order line part of the sale order form.
  • The custom model contains a computed float field called total.  This works perfectly as expected.
  • The custom model has an onchange on sale order line which updates product_uom_qty.

When a new custom model is created the onchange is called and product_uom_qty updates correctly along with dependent fields such as subtotal, cascading through onchanges.

When an existing custom model record is edited in a popup modal, the model total updates and on save the onchange is called and I can see uses the correct values however the form or record is never updated.  It even triggers the out of stock warning of the product_uom_change with the correct quantity. How to get it to update?

The onchange code has changed significantly as I've hacked at it (different field depends, trying different things like setting dirty flags, clearing caches) but in simplest terms it looks like this when it works for a new record and this also triggers the product_uom_qty onchanges and raises the warning for existing records.

def custom_id_change(self):
if self.custom_id:
self.product_uom_qty =

Kind regards,

Post to:

Post to: