Odoo Help


This community 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.


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

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

Systems Engineer + MBA

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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