I needed to change some attributes of the 'stock.move' popup screen that opened when one need to add a product in a delivery order screen, I added the following code
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): if context is None: context = {} res = super(stock_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) if context.get('picking_type') and context['picking_type']=='out': doc = etree.XML(res['arch']) domain ="[('use_type','=','finished')]" nodes = doc.xpath("//field[@name='product_id']") for node in nodes: node.set('domain', domain) node.set('string', 'Finished Product') nodes2 = doc.xpath("//field[@name='prodlot_id']") for node in nodes2: node.set('readonly',"1") node.set('invisible',"1")
node.set('string',"1==================") res['arch'] = etree.tostring(doc)
The first nodes loop worked ok, the second one, nodes2, didn't work, i.e, the field still available and editable. I added the last line for test and for surprise it worked. Any idea is appreciated
try node.set('readonly', '1')
No difference. Any more suggestions??