Odoo Help

Welcome!

This community 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.

0

Unknown field in fields_view_get with custom fields

By
Raffaele
on 3/3/15, 10:13 AM 1,398 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

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

zbik
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.

Raffaele
on 3/3/15, 11:37 AM
1

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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