콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
4092 화면

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.

베스트 답변

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

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

작성자

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}

작성자

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