Hi,
How can I make many2one field as read only in onchange functionality of odoo?. Please suggest where i am wrong in below code.
def onchange_product_id(self, cr, uid, ids, product_id=None, size_id=None, context={}):
size_id = fields.many2one('ring.size', 'Ring size')
tmpl_id = self.pool.get('product.product').browse(cr, uid, product_id).product_tmpl_id.id
if tmpl_id:
sql = """SELECT * FROM product_ring_size_default_rel
WHERE product_id = {}""".format(tmpl_id)
cr.execute(sql)
if not cr.fetchall():
size_id = fields.many2one('ring.size', 'Ring size', readonly=True)
Please specify the form which field to which field you want to readyonly
Explain it bit properly not only with single method (specify model and its related field in xml )
Try this idea: https://goo.gl/BCxCpk