And*_*ius 5 templates view openerp
是否可以Qweb在日历视图中使用模板?我想稍微修改它,但我所能做的就是添加要在日历项中显示的新字段,如下所示 - field1, field2, field3.....
有没有更好的方法来自定义日历视图,就像你可以使用Qweb模板引擎看看看板视图?
例如,如果我这样使用:
    <record model="ir.ui.view" id="view_calendar_service_work_calendar">
        <field name="name">Service Works Calendar</field>
        <field name="model">calendar.service.work</field>
        <field name="priority" eval="1"/>
        <field name="arch" type="xml">
            <calendar string="Service Works" date_start="start_time" color="employee_id" date_stop="end_time" mode="week">
                <field name="name"/>
                <field name="employee_id"/>                                     
                <template>
                    <t t-name="something"></t>
                </template>
            </calendar>
        </field>
    </record>  
Run Code Online (Sandbox Code Playgroud)
这会抛出错误:
Uncaught TypeError: Cannot read property 'type' of undefined 
http://localhost:8090/web_calendar/static/src/js/web_calendar.js:414
事实上,如果我使用除field标签之外的任何其他东西,它将抛出该错误.我甚至不能使用div标签.所以看来你根本不能设置日历样式?
日历视图不太可定制,因为它自己的设计已经很复杂了。使用不同的小部件它可能仍然可以工作。您可以使用:
    <field name="someField" widget="yourWidget"/>
如果可行,您可以使用您选择的模板编写自己的小部件。
设置您自己的小部件不需要太多代码,但需要了解 Odoo Web 客户端。
请参阅此处了解文档的特定部分,并附有一个最小的示例: https://www.odoo.com/documentation/8.0/howtos/web.html#creating-a-new-type-of-field