I have an onchange method describe in the model and based on that values i want to store values in the read-only fields, its happen buts while saving its gone.
######################################
@api.onchange('product_id')
def onchange_product_id(self):
cr = self.env.cr
desc = ''
uom = -1
for rec in self:
cr.execute('''SELECT
product_uom.id AS uom,
product_template.name AS desc,
product_hsn_tax_code.hsn_name AS hsn_code,
product_hsn_tax_code.tax_percentage AS gst_value
FROM
product_uom JOIN
product_template ON
product_uom.id=product_template.uom_id JOIN
product_product ON
product_template.id=product_product.product_tmpl_id JOIN
product_hsn_tax_code ON
product_hsn_tax_code.id=product_template.hsn_id
WHERE
product_product.id = cast(%s AS INTEGER)''', ((rec.product_id.id),))
for line in cr.dictfetchall():
uom = line['uom']
desc = line['desc']
return {'value' :{
'uom_id':uom,
'description':desc,
}}
########################################