gpt4 book ai didi

odoo - 搜索 View 域错误

转载 作者:行者123 更新时间:2023-12-04 02:17:35 28 4
gpt4 key购买 nike

有一个带有时间表模块(自制)的odoo系统。我制作了 2 组搜索 View 过滤器::

<!--Timesheets-ALL Tab search view-->
<record id="view_tabel_search3" model="ir.ui.view">
<field name="name">tabel.tabel.search3</field>
<field name="model">tabel.tabel</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Checker">
<group expand="0" string="Years">
<filter
string="Last year"
name="filter5"
domain="[('time_end_t', '&gt;=' ,(context_today()-relativedelta(years=1)).strftime('%Y-01-01')), ('time_end_t', '&lt;' , (context_today()).strftime(
help = "Shows timesheets for last year"/>
<separator/>
<filter
string="Current year"
name="filter4"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-01-01')), ('time_end_t', '&lt;' , (context_today()+relativedelta(years=1)).strftime(
help = "Shows timesheets for current year"/>
<separator/>
<filter
string="Next year"
name="filter6"
domain="[('time_end_t', '&gt;=', (context_today()+relativedelta(years=1)).strftime('%Y-01-01')),('time_end_t','&lt;=', (context_today()+relativedelt
help = "Shows timesheets for next year"/>
</group>
<group expand="0" string="Months">
<filter
string="January"
name="filter7"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-01-01')), ('time_end_t', '&lt;' , (context_today()).strftime('%Y-02-01'))]"
help = "Shows timesheets for january"/>
<separator/>
<filter
string="February"
name="filter8"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-02-01')), ('time_end_t', '&lt;' , (context_today()).strftime('%Y-03-01'))]"
help = "Shows timesheets for february"/>
<separator/>
...
<filter
string="November"
name="filter17"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-11-01')), ('time_end_t', '&lt;' , (context_today()).strftime('%Y-12-01'))]"
help = "Shows timesheets for november"/>
<separator/>
<filter
string="December"
name="filter18"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-12-01')), ('time_end_t', '&lt;' , (context_today()+relativedelta(years=1)).strftime(
help = "Shows timesheets for december"/>
</group>
<field name="time_start_t" select="True"/>
<field name="id_ank" select="True"/>
</search>
</field>
</record>

time_end_ttime_start_t 是我们的时间表开始和结束的日期。如您所见, 本身将显示当年的正确时间表。以及当前年份 和任何月份 的组合。但是 去年明年 显然不会因为 (context_today()) 事情而起作用。

我认为最合乎逻辑的方法是使用 time_end_t 的年份而不是 (context_today()) 的年份(仅当前)。但是我有一个错误(在翻译中),比如

  Unable to process the search criteria
...
name 'time_end_t' is not defined

例如当我写这样的东西时:

  <field name="time_end_t" />
<filter
string="January"
name="filter7"
domain="[('time_end_t', '&gt;=' , time_end_t )]"
help = "Shows timesheets for january (not actually)"/>

但是它在上面定义了..任何建议将不胜感激!

更新:工作代码示例(针对 Odedra):

<page string="Timesheet's data">
<table style="width:100%;">
<tr>
<field name="state" widget="statusbar" string="document's status"/>
</tr>
<tr><td>
<group>
<field name="time_start_t" string="Timesheet's start date" />
<field name="time_end_t" string="Timesheet's end date" />
</group></td><td>
<group>
<field name="id_division" string="Division" domain="[('enddate','&gt;=',time_start_t),('startdate','&lt;=',time_end_t) ]"/>
<field name="id_ank" string="Tableman" />
<field name="dayall"/>
</group></td></tr>
</table>
</page>

最佳答案

一切正常。当我们在域上使用任何字段时,我们必须注册该字段。意味着我们需要在搜索 View 的第一行定义该字段。

试试这个代码:

<!--Timesheets-ALL Tab search view-->
<record id="view_tabel_search3" model="ir.ui.view">
<field name="name">tabel.tabel.search3</field>
<field name="model">tabel.tabel</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Checker">
<field name="time_start_t" select="True"/>
<field name="id_ank" select="True"/>
<group expand="0" string="Years">
<filter
string="Last year"
name="filter5"
domain="[('time_end_t', '&gt;=' ,(context_today()-relativedelta(years=1)).strftime('%Y-01-01')), ('time_end_t', '&lt;' , (context_today()).strftime(
help = "Shows timesheets for last year"/>
<separator/>
<filter
string="Current year"
name="filter4"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-01-01')), ('time_end_t', '&lt;' , (context_today()+relativedelta(years=1)).strftime(
help = "Shows timesheets for current year"/>
<separator/>
<filter
string="Next year"
name="filter6"
domain="[('time_end_t', '&gt;=', (context_today()+relativedelta(years=1)).strftime('%Y-01-01')),('time_end_t','&lt;=', (context_today()+relativedelt
help = "Shows timesheets for next year"/>
</group>
<group expand="0" string="Months">
<filter
string="January"
name="filter7"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-01-01')), ('time_end_t', '&lt;' , (context_today()).strftime('%Y-02-01'))]"
help = "Shows timesheets for january"/>
<separator/>
<filter
string="February"
name="filter8"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-02-01')), ('time_end_t', '&lt;' , (context_today()).strftime('%Y-03-01'))]"
help = "Shows timesheets for february"/>
<separator/>
...
<filter
string="November"
name="filter17"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-11-01')), ('time_end_t', '&lt;' , (context_today()).strftime('%Y-12-01'))]"
help = "Shows timesheets for november"/>
<separator/>
<filter
string="December"
name="filter18"
domain="[('time_end_t', '&gt;=' ,(context_today()).strftime('%Y-12-01')), ('time_end_t', '&lt;' , (context_today()+relativedelta(years=1)).strftime(
help = "Shows timesheets for december"/>
</group>
</search>
</field>
</record>

关于odoo - 搜索 View 域错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33012722/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com