【发布时间】:2019-02-06 10:03:06
【问题描述】:
我在视图元素中为颜色参数传递值时遇到问题。 所以我有我的模型,它具有返回颜色的功能:
class MyTask(models.Model):
_inherit = "project.task"
is_special=fields.Boolean()
@api.model
def get_colors(self):
return 'red: is_special == true;'
我也有这样的看法:
<record id="my_module_timeline" model="ir.ui.view">
<field name="model">project.task</field>
<field name="type">timeline</field>
<field name="arch" type="xml">
<timeline date_start="date_start"
date_stop="date_end"
default_group_by="project_id"
event_open_popup="true"
colors= <-- how can i get the value from my model get_colors() function?
>
</timeline>
</field>
colors 参数必须是字符串,不能是模型字段。 我尝试了很多选项来从模型函数中获取这个字符串,但没有好的结果。
<timeline> 元素只是示例,它也可以是树、日历等。
对于测试我从:
https://github.com/OCA/web/tree/11.0/web_timeline
这样可以吗?
谢谢。
【问题讨论】:
标签: python python-3.x odoo odoo-10 odoo-11