This question has been flagged
1 Reply
3457 Views

Hi

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

Thanks

Avatar
Discard

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

Best Answer

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.

 

Avatar
Discard
Author

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

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

Author

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}

Author

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}

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

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