Odoo Help

0

Field readonly don't stored in database

By
oussama
on 10/20/14, 4:33 AM 922 views

Hi

Field readonly don't stored in database when i use onchange method

Thanks

Thats because they are readonly..... You can either redefine the field not to be readonly, or change the field using some other way.

Ludo - Neobis
on 10/20/14, 5:26 AM
0
Anup Kandalkar
On 10/20/14, 5:02 AM

Hi Oussama,

Here you have to override this readonly field value in create and write method also based on onchange field value. First you have to check the value of onchange field and according that update vals in create and write method. Hope this will help.

 

Thanks Anup for your help,but idon't understand your response,if you can give me an example. Thanks

oussama
on 10/20/14, 5:36 AM

you have to write same code in both methods (create and write) which you have write in onchange method.

Anup Kandalkar
on 10/20/14, 6:06 AM

i use this code in my onchange method is stored in database but i can't edit it def fret_change (self,cr, uid,ids ,tva_p,t_c,prix_d,fret_p,context): vals={} vals['p_achat_ht']= (t_c*prix_d)*(1+(fret_p/100)) self.write(cr, uid,ids, vals,context=context) return {'value': vals}

oussama
on 10/20/14, 6:09 AM

i use this code in my onchange method is stored in database but i can't edit it def fret_change (self,cr, uid,ids ,tva_p,t_c,prix_d,fret_p,context): vals={} vals['p_achat_ht']= (t_c*prix_d)*(1+(fret_p/100)) self.write(cr, uid,ids, vals,context=context) return {'value': vals}

oussama
on 10/20/14, 6:10 AM

//Onchange method, try this way def fret_change(self, cr, uid, ids, prod_id=False, context=None): res = {} if prod_id: res['readonly_field']=value return {'value':res} //Create method def create(self, cr, uid, vals, context=None): if 'prod_id' in vals: vals['readonly_field'] = value //value may be calculate return super(object, self).create(cr, uid, vals, context) //Write Method def write(self, cr, uid, ids, vals, context=None): if 'prod_id' in vals: vals['readonly_field'] = value //value may be calculate return super(object, self).write(cr, uid, ids, vals, context)

Anup Kandalkar
on 10/20/14, 9:07 AM
hi Anup

the function is not working,Idon't understand why you add prod_id=False in parameters of method

Thanks a lots

2014-10-20 14:07 GMT+01:00 Anup Kandalkar <kandalkar.a87@gmail.com>:

//Onchange method, try this way def fret_change(self, cr, uid, ids, prod_id=False, context=None): res = {} if prod_id: res['readonly_field']=value return {'value':res} //Create method def create(self, cr, uid, vals, context=None): if 'prod_id' in vals: vals['readonly_field'] = value //value may be calculate return super(object, self).create(cr, uid, vals, context) //Write Method def write(self, cr, uid, ids, vals, context=None): if 'prod_id' in vals: vals['readonly_field'] = value //value may be calculate return super(object, self).write(cr, uid, ids, vals, context)

--
Anup Kandalkar
Sent by OpenERP S.A. using Odoo about Forum Post False

oussama
on 10/20/14, 12:41 PM

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.

Register

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

2 follower(s)

Stats

Asked: 10/20/14, 4:33 AM
Seen: 922 times
Last updated: 3/16/15, 8:10 AM