'Add attribute on_change="1" on fields that are dependencies of
computed fields on the same view.'

def add_on_change(self, model_name, arch):

    field_nodes = collections.defaultdict(list)
    def collect(node, model):
        if (node.tag == 'field'):
            field = model._fields.get(node.get('name'))
            if field:
                field_nodes[field].append(node)
                if field.relational:
                    model = self.env[field.comodel_name]
        for child in node:
            collect(child, model)
    collect(arch, self.env[model_name])
    for (field, nodes) in field_nodes.iteritems():
        model = self.env[field.model_name]
        if model._has_onchange(field, field_nodes):
            for node in nodes:
                if (not node.get('on_change')):
                    node.set('on_change', '1')
    return arch
