Odoo Help


Unknown field in fields_view_get with custom fields

on 3/3/15, 10:13 AM 2,542 views

Hallo I am dealing with this code in Odoo v8:

from openerp import models, fields
from lxml import etree
from openerp.osv.orm import setup_modifiers

class calendar_event(models.Model):

    _inherit = "calendar.event"

    model = fields.Char('Model')
    external_id = fields.Integer("External ID")

    def fields_view_get(self, cr, uid, view_id=None, view_type=None, context=None, toolbar=False, submenu=False):

        res = super(calendar_event, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type,
                                                            context=context, toolbar=toolbar, submenu=submenu)

        if view_type == 'form':
            # Set all fields read only when coming from an external model
            doc = etree.XML(res['arch'])
            for node in doc.xpath("//field"):
                node.set('attrs', "{'readonly': [('model', '!=', False)]}")
                node_name = node.get('name')
                setup_modifiers(node, res['fields'][node_name])

            res['arch'] = etree.tostring(doc)

        return res

I am getting the error "Uncaught Error: Unknown field model in domain [["model","!=",false]]".

Any hint please?


Due to the weird "Karma requirements" I cannot comment the answer given by Zbik, which is correct and solve my issue. Thank you

1) model - is reserved word 2) You have this field in database - verify?

on 3/3/15, 10:51 AM

thank you zbik fro replying. The field "model" gets created in the database and correctly filled; btw I renamed it to "external_model" but the issue remains.

on 3/3/15, 11:37 AM


| 6 5 7
Lodz, Poland

On 3/3/15, 12:38 PM

Probably you have to add a field model (external_model), to your XML view, external_model node name must exist.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/3/15, 10:13 AM
Seen: 2542 times
Last updated: 3/16/15, 8:10 AM