窗口操作

阅读(45) 最后更新: 2019年2月6日 04:47

上一页 菜单项 | 表单视图结构 下一页

翻译进度 100%

自助翻译

窗口操作给GUI客户端提供指令,并且通常被视图中的菜单项或按钮使用。它告诉GUI要处理的模型和要使用的视图。这些操作可以使用域筛选器过滤可用的记录,并可以通过上下文属性设置默认值和筛选器。
A Window Action gives instructions to the GUI client and is usually used by menu items or buttons in views.It tells the GUI which model to work on and which views to make available.These actions can filter the records to be available, using a domain filter, and can set default values and filters through the context attribute.
窗口操作存储在ir.actions.act_Window模型中,可以通过Settings_TechnicalActions_Window操作菜单浏览。
Window Actions are stored in the ir.actions.act_window model and can be browsed via the Settings | Technical | Actions | Window Actions menu.
在Library_checkout/view/Library_menu.xml中,我们可以找到在签出菜单项中使用的窗口操作。我们需要对其进行更改,以启用本章中将添加的其他视图类型:name=“checkout”res_model=“labary.checkout”view_mode=“tree,form,Activity,日历,图表”,“透视”/>窗口操作通常使用前面使用的快捷方式创建。
In library_checkout/views/library_menu.xml, we can find the Window Action used in the checkout menu item.We need to make a change to it to enable the additional view types we'll add in this chapter: name="Checkouts" res_model="library.checkout" view_mode="tree,form,activity,calendar,graph,pivot" /> Window Actions are usually created using the shortcut, used previously.
我们正在将视图模式从“树,形式”更改为更大的“树、形式、活动、日历、图表、枢轴”列表。
We're changing view_mode from "tree, form" to the larger "tree,form,activity,calendar,graph,pivot" list.
使用的窗口操作属性如下:Name是将显示在通过此操作打开的视图上的标题。
The Window Action attributes used are as follows: name is the title that will be displayed on the views opened through this action.
res_model是目标模型的标识符。
res_model is the identifier of the target model.
VIEW_MODE是要使用的视图类型的逗号分隔列表。默认情况下,列表中的第一个类型是打开的。
view_mode is a comma-separated list of the view types to make available.The first in the list is the one to open by default.
其他窗口操作属性如下:如果设置为New,则将在弹出对话框窗口中打开视图,例如,Target=“new”。默认情况下,它是当前的,在主内容区域内以内联方式打开视图。
Other Window Action attributes are the following: target, if set to new, will open the view in a pop-up dialog window, for example, target="new".By default, it's current, opening the view inline in the main content area.
上下文设置目标视图的上下文信息,可以设置默认值或激活筛选器,例如,Context=“{‘Default_user_id’:UID}”。
context sets context information on the target views, which can set default values or activate filters, among other things, for example, context="{'default_user_id': uid}".
域是一个域表达式,强制对可以在打开的视图中浏览的记录进行筛选,例如域=“[(‘user_id’,‘=’,uid)]”。
domain is a domain expression forcing a filter for the records that can be browsed in the opened views, for example,domain="[('user_id', '=', uid)]".
限制是每个页面的记录数,例如,List视图中的Limit=“80”。
limit is the number of records for each page, in the list view, for example,limit="80".
安装这些更改后,当您选择“结帐”菜单项并导航到相应的列表视图时,将在右上角、列表和窗体按钮之后出现额外的按钮,但是,在我们创建相应的视图之前,这些按钮将无法工作,我们将在本章后面讨论。
After these changes are installed, when you select the Checkouts menu item and navigate to the corresponding list view, there will be additional buttons in the top-right corner, after the list and form buttons.However, these won't work until we create the corresponding views, which we'll cover later in this chapter.
窗口操作也可以从“操作”菜单按钮中使用,该按钮位于列表顶部和窗体视图的旁边,位于筛选器按钮旁边。为此,我们需要向元素添加两个属性:src_model设置将使操作可用的模型,例如src_model=“Library ary.checkout”。
Window Actions can also be used from the Action menu button, available at the top of the list and form views, next to the Filters button.For this, we need to add two more attributes to the element: src_model sets the model where the action will be made available, for example, src_model="library.checkout".
Multi-=“true”还启用了List视图上的操作,以便它可以处理多个选定的记录。否则,它只能在Form视图中使用,一次只能应用于一条记录。
multi="true" enables the action on the list view also, so that it can work on multiple selected records.Otherwise, it's available only in the form view, and can only be applied to one record at a time.

odoo技术交流2 群号 625337975

http://www.odoogo.com/post/58/Odoo开发视频教程

文档不断更新中,添加微信odoogo,获取最新视频课程和模块

留言提问