İçereği Atla
Menü
Bu soru işaretlendi
4 Cevaplar
251 Görünümler

Hi!!!!!!

Please who can help me please!!!

i want to change the value of a field in class a with a value of a field in class b.

Please i need your help

Avatar
Vazgeç
Üretici

Please , there is no one to give me even a simple example :/

Can you describe more for clearly understand. Also give example what you want.

En İyi Yanıt

Dear Abdelwahed,

There are lots of examples of onchange in addons.

Here I given simple example of onchange method

Definition of on change methods in a view looks like this:

<field name="name" on_change="name_change(name, address, city)"/>

And here is the corresponding method in the model:

def name_change(self, cr, uid, ids, name, address, city, context=None):

...

    return {

        'value': {

            'address': ...

            'city': ...

        }

}

2nd Example

In xml file or view file.

<field name="partner_id" on_change="onchange_partner(partner_id)"/>

In python file or model file

def onchange_partner(self, cr, uid, ids, partner_id, context=None):

res = {}

if partner_id:

    obj = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)

    res['field1'] = obj.field1

    res['field2'] = obj.field2

    res['field3'] = 'Hello' # this field type must be char or if not then give

    #value accordingly, its just to prove you that values are filled on onchange.

    return {'value': res}

Hope this will help you. 

Thanks & Regards

Ankit H Gandhi

Avatar
Vazgeç
Üretici

Ankit Gandhi Thanks for your answers. That is very helpful ;)

En İyi Yanıt

inherit class a in b, then change your field value.

Avatar
Vazgeç
Üretici

Guys!!!!! Thanks a lot for your answers. But nothing works fine. I want to know how to change the value of the field when i am not in its class. Here is what i have done: I have inhereited class a in b and then i have done: obj7 = self.pool.get('project.service.line') obj_ids7 = obj7.search(cr, uid, [('project_id', '=', res9[0]['id']),('int_services', '=', name_service)]) res7 = obj7.read(cr, uid, obj_ids7, ['points_charges','credit_service'], context) print res7 return {'credit_service':credits} but... :/

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Nis 24
1938
4
Kas 23
6036
0
Eki 23
1793
0
Ara 22
2682
2
Ara 23
19454