Odoo Help

Welcome!

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.

0

function field

By
zineb
on 3/10/13, 5:40 PM 1,360 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),

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

Cyril Gaspard (GEM)
on 3/10/13, 6:22 PM
1

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 3/10/13, 7:34 PM

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

0
zineb
On 3/10/13, 6:29 PM

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),

}

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)

Stats

Asked: 3/10/13, 5:40 PM
Seen: 1360 times
Last updated: 3/16/15, 8:10 AM