如何在Odoo 11的日历视图中显示自己的看板卡? [英] How to display your own kanban card in calendar view in Odoo 11?
问题描述
我正在尝试自定义calendar.event
模型的日历视图,其代码为:
I am trying to customise the calendar view of the calendar.event
model, whose code is:
<record id="view_calendar_event_calendar" model="ir.ui.view">
<field name="name">calendar.event.calendar</field>
<field name="model">calendar.event</field>
<field name="priority" eval="2"/>
<field name="arch" type="xml">
<calendar string="Meetings" date_start="start" date_stop="stop" date_delay="duration" all_day="allday"
display="[name]" color="color_partner_id" attendee="partner_ids" avatar_model="res.partner"
use_contacts="True" event_open_popup="%(calendar.view_calendar_event_form_popup)s">
<field name="name"/>
<field name="user_id"/>
<field name="color_partner_id"/>
<field name="partner_ids"/>
</calendar>
</field>
</record>
我想显示一些新字段并使背景颜色依赖于名为color_confirmed
的新字段.完美的方法是将日历视图中显示的看板替换为自定义的看板. Odoo文档( https://www.odoo.com/documentation/11.0/reference/views.html#calendar )表示以下内容:
I want to show some new fields and make the background color depend on a new field named color_confirmed
. The perfect way would be to replace the kanban shown in the calendar view by a customised one. The Odoo documentation (https://www.odoo.com/documentation/11.0/reference/views.html#calendar) says the following:
模板
定义QWeb模板日历框.为了清楚起见,卡的定义可以分为多个模板,每条记录将呈现一次.
defines the QWeb template calendar-box. Cards definition may be split into multiple templates for clarity which will be rendered once for each record.
看板视图使用大多数标准的javascript qweb并提供以下上下文变量:
The kanban view uses mostly-standard javascript qweb and provides the following context variables:
...
我正在尝试使用该 templates 属性,但是我不知道如何使用,也无法在我下载的所有可用模块中找到示例.我的尝试之一:
I am trying to use that templates attribute, but I have no idea how, and I was not able to find an example in all the available modules I have downloaded. One of my attempts:
<record id="view_calendar_event_calendar" model="ir.ui.view">
<field name="name">calendar.event.calendar</field>
<field name="model">calendar.event</field>
<field name="inherit_id" ref="calendar.view_calendar_event_calendar"/>
<field name="arch" type="xml">
<xpath expr="//calendar[1]" position="replace">
<calendar string="Meetings" date_start="start" date_stop="stop" date_delay="duration"
all_day="allday" display="[color_confirmed]" color="color_confirmed" attendee="partner_ids"
avatar_model="res.partner" use_contacts="False" event_open_popup="%(calendar.view_calendar_event_form_popup)s" mode="month">
<field name="name"/>
<templates>
<t t-name="calendar-box">
<div class="oe_kanban_global_click">
<div class="oe_kanban_details">
<strong class="oe_partner_heading"><field name="name"/></strong>
<ul>
<li>TEST ITEM 1</li>
<li>TEST ITEM 2</li>
</ul>
</div>
</div>
</t>
</templates>
</calendar>
</xpath>
</field>
</record>
如预期的那样,它将引发JS错误.我已经尝试了几种方法,但在这样的一项任务上浪费了很多时间.有谁知道它是如何工作的? (或者是实现我的目标的更好方法).
As expected, it throws a JS error. I have tried several ways and I am wasting a lot of time in such a single task. Does anyone have an idea of how this works? (or a better way to achieve my purpose).
推荐答案
js错误应归因于日历定义中的avatar_model
,use_contacts
和attendee
.因为日历不接受这些值.
the js error should be because of the avatar_model
, use_contacts
, and attendee
in the calendar definition. because the calendar is not accepting those values.
如果您删除这些字段并添加代码,则效果会很好.在这里,我已经渲染了您的calendar-box
模板
if you remove those fields and add your code will work well. here I have rendered your calendar-box
template
让我知道我是否想念任何东西.
Let me know if I am missing anything.
这篇关于如何在Odoo 11的日历视图中显示自己的看板卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!