Hi
How to store field readonly in database with onchange method
my code :
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))
return {'value': vals}
def write(self,cr, uid, ids, vals, context=None):
for rec in self.browse(cr, uid, ids, context=context):
#Pass required value of fields in onchange
res = self.fret_change(cr, uid, [rec.id], rec.tva_p, rec.t_c,rec.prix_d,rec.fret_p,context)
if res.has_key('p_achat_ht'):
vals.update({'p_achat_ht': res.get('p_achat_ht')})
return super(product_product, self).write(cr, uid, ids, vals, context=context)
def create(self,cr, uid, vals, context=None):
#Pass required value of fields in onchange
res = self.fret_change(cr, uid, [], vals.get('tva_p'),vals.get('t_c'), vals.get('prix_d'),vals.get('fret_p'),context)
if res.has_key('p_achat_ht'):
vals.update({'p_achat_ht': res.get('p_achat_ht')})
return super(product_product, self).create(cr, uid, vals, context=context)
thanks
Try this: https://learnopenerp.blogspot.com/2021/10/onchange-method-readonly-field-not-store-database-odoo.html