Odoo Help


Problem calling self.write() where object has fields.function

Zeno Trevisan
on 10/2/14, 2:44 PM 3,592 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)

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


Grover Menacho

--Grover Menacho--
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Odoo Developer

Grover Menacho
On 10/2/14, 7:06 PM

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.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/2/14, 2:44 PM
Seen: 3592 times
Last updated: 3/16/15, 8:10 AM