跳至内容
菜单
此问题已终结
2 回复
12129 查看

Hi everyone,

I'm using Odoo 10 and try to customize a view in my module.

My code:

<record id="view_calendar_event_form_popup" model="ir.ui.view">

        <field name="name">calendar.event.form</field>
        <field name="model">calendar.event</field>
        <field name="inherit_id" ref="calendar.view_calendar_event_form_popup"/>
        <field name="priority" eval="2"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='alarm_ids']" position="after">
                <field name="delete_series" attrs="{'invisible': [('recurrency', '=', False)]}"/>
            </xpath>
        </field>
    </record>

But when opening the form, I got this error:

Uncaught Error: Unknown field recurrency in domain [["recurrency","==",false]]

And I'm sure that the field 'recurrency' is existing in the object 'calendar.event'

Did I make something wrong?

Thank you.

形象
丢弃

Please do not mix questions.

最佳答案

Hello Vu Huynh,


recurrency field must be in calendar.event model.

You have to add this field also in the view.


Try this :-

<record id="view_calendar_event_form_popup" model="ir.ui.view">
    <field name="name">calendar.event.form</field>
    <field name="model">calendar.event</field>
    <field name="inherit_id" ref="calendar.view_calendar_event_form_popup"/>
    <field name="priority" eval="2"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='alarm_ids']" position="after">
            <field name="recurrency" invisible="1"/>
            <field name="delete_series" attrs="{'invisible': [('recurrency', '=', False)]}"/>
        </xpath>
    </field>
</record>


Hope it will works for you.

Thanks,

形象
丢弃
编写者

Thank you Jignesh,

One more thing, I define the field 'delete_series' in my custom module. And I don't want to store it in db, just want to display it as a checkbox to user.

delete_series = fields.Boolean("Delete in series", store=False)

But, it's always shown in the view as read-only field.

How can I enable for user check on it?

Thank you