This question has been flagged
1 Reply
6216 Views

Dear All

I have follwing scenario using Openerp 7.0:

class sometest(orm.Model)
    _name = 'test.test'

    _column {
        'field1': fields.function(some_function, type='float', store={'some.model': (other_function, [some_trigger],10)}),
        'field2': fields.function(also_function, type='float', store=True),
        ...
        }

def _prepareSomeValues(self, cr, uid, vals, context=None):
    do some stuff to prepare vals as {'record_id': float_value}
    ...
    obj = self.pool.get('test.test)
    obj._updateRecordsWithField1(cr, uid, vals, context=context)
    ...
    return

def _updateRecordsWithField1(self, cr, uid, vals, context=None):
        for record in vals:
            self.write(cr, uid, [record], {'field1': vals[record],}, context=context)

        return True


When trying to update field1 via the function _prepareSomeValues(), I do observe that the self.write function is called, however during processing the write it additionally calls the also_function for field2 and returns finally without updating field1, but also without any trace of an error or another problem. The inputs for the write function appear correct (record has valid object id, value of vals[record] has valid float).

How can I avoid triggering functions for field2 which I do not want to update and achieve effective writing of field1 values?

thanks in advance for any help

Avatar
Discard
Best Answer

You can't write directly on function fields. On that case you only have to use another type of field like char, float, integer.... If you are using a function field you're telling the system that you're not going to fill that and that the function is going to fill that field always.

Avatar
Discard