This question has been flagged

Hi everyone,

Either I came across on some interesting "bug" or I'm doing something wrong. Anyhow, here is what I've been trying to accomplish: Create a dynamic view with some readonly fields on it. Here is the code example:

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
    result = super(automatic_invoice_processor, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
    ...
    result['fields'][field_name2] = {
        'domain': [],
        'selectable': True,
        'views' : {},
        'relation' : 'account.invoice',
        'context' : {},
        'type' : 'many2one',
        'readonly': True
    }
    ...
    field = '<field name="%s" /> <field name="%s" nolabel="1" readonly="1" />' % (field_name1,field_name2)
    ...
    return result

First I tried adding readonly attribute on the view level, then on the actual field definition and then both. Nothing worked :(

Did anyone come across anything similar? Any help would be much appreciated.

Avatar
Discard
Best Answer

HI, you can follow following tutorial for this:

https://youtu.be/kwkddYoFQCE

Hope it helps,

Thanks

Avatar
Discard