콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
9015 화면

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?

작성자

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.

베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
1
5월 24
2597
1
11월 22
4931
2
7월 22
3675
2
9월 18
9677
2
5월 18
9831