Debug default, on_change, onchange_with values of a field


(udono) #1

Hi there,

the evolution of a default field value with a lot of on_change and on_change with values is sometimes not
easy to track. I would like to ask your methods and strategies to find out why a default field value is
as it is on creating a new record.
On creating new records, the default value is set reliable. But after the defaults are applied,
Tryton executes on_changes and on_change_with methods, which could change the former default.

  1. Is there a way to determine all executed on_change and on_change_with methods in order of execution?
  2. Is there a way, to catch the latest method call which fills a field?

Regards Udo


(udono) #2

Answering my questions is no longer needed. I did not find a better way to debug than using pdb
and the REPL. My problem was an on_change call inside another on_change call, which did not
define the depends of the inner on_change call.
The solution is to add a methods attribute to the depends decorator with the method name of the inner on_change call similar to this example from sale module:

@fields.depends(methods=['on_change_quantity'])
def on_change_unit(self):
    self.on_change_quantity()

(Diego Abad) #3

Seems that this apply only on version >= 5.0, can you confirm this please?


(Sergi Almacellas Abellana) #4

Since version 5.0 depends can be used to depend on any method, previously you can add a dependency to between on_change methods. So using

@fields.depends(methods=['quantity'])
def on_change_unit(self):
   self.on_change_quantity()

Is the equivalent code since version 3.2.