This question has been flagged
1 Reply
7912 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?

UPDATE

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

Avatar
Discard

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

Author

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.

Best Answer

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

Avatar
Discard