This question has been flagged
2 Replies
3676 Views

I have two objects linked by one2many, the first object contains a function field, and the second object contains a function field too, now when i modify the first function field, the modification is not done on the second function in the second object,

How can I trigger the modification of the second field when I change the first field ?

    'partie1': fields.function(_get_partie1, method=True, type='char', string=u'Partie 1', store=True),
Avatar
Discard

Hi,the function field in one2many depend of the result of parent class ? Bye

Best Answer

Hi

no need to add an answer, just update your question.

If I well understood, you want to display in yours lines one2many the value of field partie1 of parent class. Where is the field one2many in your class doo_notariat ? Where is the field type many2one in class notariat_repertoire (repertoire = directory in english) which do relation with class parent doo_notariat Else, For that you just have to use a fields.related, not a fields.function, by using partie1_in_2_id:

fields.related('field many2one of relation to parent class which is also present as attribute in field on2many in parent class', 'partie1', relation='doo.notariat', type='char', size='size_you_need', store=True, string="Partie 1"),

but modification will be done I think when you will save you record.

Bye

Avatar
Discard
Author Best Answer

yes

this is my code :

the first object :

classer doo_notariat {

    'partie1': fields.function(_get_partie1, method=True, type='char', string=u'Partie 1', store=True),

}

the second object :

class notariat_repertoire(osv.osv):

def _get_funcion(self, cr, uid, ids, name, args, context):
    if not ids: return {}
    res = {}
    for line in self.browse(cr, uid, ids, context=context):
        res[line.id] = line.dossier_id.partie1
    return res 

_columns = {

    'partie1': fields.function(_get_function, method=True, type='char', string=u'Partie 1', store=True),

}

Avatar
Discard