Odoo View operation

Source: Internet
Author: User

* Window operation
Some of the following code
<?xml version= "1.0" encoding= "Utf-8"?>
<openerp>
<data>
<act_window id= "Action_todo_stage"
Name= "To-do Task Stages"
Res_model= "Todo.task.stage"
View_mode= "Tree,form"/>

<act_window id= "Todo_app.action_todo_task"
Name= "To-do Task"
Res_model= "Todo.task"
View_mode= "Tree,form,calendar,gantt,graph"
target= "Current"
context= "{' default_user_id ': uid}"
Domain= "[]"
Limit= "/>"
<act_window id= "Action_todo_task_stage"
Name= "To-do Task Stages"
Res_model= "Todo.task.stage"
Src_model= "Todo.task"
multi= "False"/>
</data>

</openerp>

The action of the window is in the Ir.actions.act_window model, we can quickly define it in the XML file using <act_window>.
# NAME Displays the title
# Target model for Res_model action response
# View_mode list action responses corresponding to available view types
# Target opens a new window if it is set to the default is current
# contexts set the context of the target view
# Domain filter records by condition
# limit refers to the number of records on a page when the list view, default is 80

# Src_model Specify more buttons to start the view
# Multi is set to True, more buttons are displayed in the list view, otherwise displayed in the Form view

* Menu item
Some of the following code

<menuitem id= "Menu_todo_task_main"
Name= "to-do" parent= "Mail.mail_my_stuff"/>
<menuitem id= "Todo_app.menu_todo_task"
Name= "To-do Tasks"
Parent= "Menu_todo_task_main"
Sequence= "10"
action= "Todo_app.action_todo_task"/>
<menuitem id= "Menu_todo_task_stage"
Name= "To-do Stages"
Parent= "Menu_todo_task_main"
Sequence= "20"
action= "Action_todo_stage"/>

Menus in the user interface, technologies-----menu to see defined menus
The menu is in the Ir.ui.menu model, and we can quickly define it in the XML file using <menuitem>.

* Contextual (context)
# context is a dictionary type of data that is used for client and server-side processing,
Can be used for information transfer between views,
Example: {' lang ': ' en_US ', ' tz ': ' europe/brussels ', ' uid ': 1}
{' default_user_id ': uid} with current user as Default user
{' Search_default_filter_my_tasks ': True}

* Domain Expression

# used to filter the number of records, equivalent to where in SQL
(' field ', ' operator ', value) each conditional expression is a tuple type
domain=[(' user_id ', ' = ', uid)] Current user as conditional filter
#操作符如下:
<,>,<=,>=,!=
=like
Like, ilike (case insensitive)
Child_of find direct and indirect sub-objects
In, not in
#条件可以用逻辑符连起来 use list types to organize
& is the meaning of and is the default
| Yes or
! The opposite meaning of right and wrong
['! ', (' user_id ', ' = ', UID)] is not a record of the current user
[' | ', (' user_id ', ' = ', uid), (' user_id ', ' = ', False)] not the current user, or no user's record
A bit more complicated:
[' | ', (' message_follower_ids ', ' in ', [user.partner_id.id]), ' | ', (' user_id ', ' = ', user.id),
(' user_id ', ' = ', False)]
Logic is even behind two domain conditions

* Form view
# Add in actions and menu items after <act_window> <menuitem>
The code is as follows:
<record id= "view_form_todo_task_ui" model= "Ir.ui.view" >
<field name= "Name" >view_form_todo_task_ui</field>
<field name= "Model" >todo.task</field>
<field name= "Arch" type= "xml" >
<form>
<sheet> <!--Form Content--</sheet>
<!--history and communication:-
<div class= "Oe_chatter" >
<field name= "Message_follower_ids"
widget= "Mail_followers"/>
<field name= "Message_ids"
widget= "Mail_thread"/>
</div>
</form>
</field>
</record>
#包含三个可视域:
<sheet> put content in
<bottom> History and social parts
# Header Status Bar
<field name= "Stage_state" invisible= "True"/>
<button name= "Do_toggle_done" type= "Object"
attrs= "{' Invisible ':
[(' Stage_state ', ' in ', [' Done ', ' Cancel '])]} "
string= "Toggle Done" class= "Oe_highlight"/>
<!--Add Stage StatusBar: ...-
@ class= "Oe_highlight" heightening light
@ invisible is visible and can also be used on other elements, not only on <botton>


* View elements
#按钮 <button>, supported properties
Icon available icon in Addons/web/static/src/img/icons
The display text of the string button
The type value can be workflow, object action
Name is the method ID to trigger
Parameters of the Args pass method
Content context
Confirm Confirmation for the dialog box
Special= "Cancel" for wizards

#字段 <field>, the properties of the payment
Name Field technical Name
String Display Name
Help Tips
Placeholder Placeholder text
Widget Small Items
Options for small items
Class name Loaded
Invisible= "1" identity is not visible
Nolabel= "1" does not display labels and will be used within <group>
Readonly= "1" identifies read-only
Required= "1" ID cannot be empty

Sum,avg Subtotal, average
password= "True" Password box
FileName file for upload
Mode= "Tree" one2many field

#关联字段
options={' No_open ': true, ' no_create ': true}
Commonly used in context and domain

# Small Items
For text fields
Email URL html
For numeric fields
Float_time Monetary ProgressBar
For associating and selecting
Many2many_tags
Selection
Radio
Kanban_state_selection
Priority

* Event Change
@api. onchange (' field1 ', ' field2 ')

* Dynamic View
# Group
# states
Increased flexibility with refers_to
<field name= "Refers_to"
attrs= "{' Invisible ': [(' state ', ' = ', ' draft ')]}"/>

* List View
<record id= "Todo_app.view_tree_todo_task" model= "Ir.ui.view" >
<field name= "name" >to-do Task tree</field>
<field name= "Model" >todo.task</field>
<field name= "Arch" type= "xml" >
<tree editable= "Bottom"
Colors= "Gray:is_done==true"
fonts= "italic:state!= ' Open '" delete= "false" >
<field name= "Name"/>
<field name= "user_id"/>
</tree>
</field>
</record>

# <tree>
Editable setting fields can be edited directly in the list
Colors set the color of the record by condition
Fonts set the font for a record by condition
Create,delete,edit is not available if set to False

* Search View
The code is as follows:
<record id= "Todo_app.view_filter_todo_task"
Model= "Ir.ui.view" >
<field name= "name" >to-do Task filter</field>
<field name= "Model" >todo.task</field>
<field name= "Arch" type= "xml" >
<search>
<field name= "name" domain_filter= "[' | ',
(' name ', ' ilike ', self), (' user_id ', ' ilike ', self)] "/>
<field name= "user_id"/>
<filter name= "Filter_not_done" string= "Not Done"
Domain= "[(' is_done ', ' = ', False)]"/>
<filter name= "Filter_done" string= "Done"
Domain= "[(' Is_done ', '! = ', False)]"/>
<separator/>
<filter name= "Group_user" string= "by user"
context= "{' group_by ': ' user_id '}"/>
</search>
</field>
</record>

# <search>
Shown above, only name and user_id search
Field element-defined properties
Name field ID Name
String Label signature
operator operator
Domain_filter filtering records by condition
Groups for grouping
Filter element Support Properties
NAME specifies the action identifier
String Label signature
Domain Filter records by condition
Content context
Groups Group List

* Calendar view
<record id= "View_calendar_todo_task" model= "Ir.ui.view" >
<field name= "Name" >view_calendar_todo_task</field>
<field name= "Model" >todo.task</field>
<field name= "Arch" type= "xml" >
<calendar date_start= "Date_deadline" color= "user_id"
Display= "[name], Stage [stage_id]" >
<!--fields used for the text of display attribute--
<field name= "Name"/>
<field name= "stage_id"/>
</calendar>
</field>
</record>
#<calendar>
Date_start Start date
Date_end End Date
Date_delay Cycle
Color-colored entities
Display text

* Gantt view
<record id= "View_gantt_todo_task" model= "Ir.ui.view" >
<field name= "Name" >view_gantt_todo_task</field>
<field name= "Model" >todo.task</field>
<field name= "Arch" type= "xml" >
<gantt date_start= "Date_deadline"
default_group_by= "user_id"/>
</field>
</record>

#<gantt>
Date_start Start date
Date_end End Date
Date_delay Cycle
Progress Progress Percentage
Default_group_by Task Grouping criteria

* Chart view
<record id= "View_graph_todo_task" model= "Ir.ui.view" >
<field name= "Name" >view_graph_todo_task</field>
<field name= "Model" >todo.task</field>
<field name= "Arch" type= "xml" >
<graph type= "pivot" >
<field name= "Stage" type= "col"/>
<field name= "user_id"/>
<field name= "Date_deadline" interval= "Week"/>
<field name= "effort_estimate" type= "measure"/>
</graph>
</field>
</record>
#<graph>
Properties supported by Fields <field>
Name field ID Name
Type grouping by default, row row, setting can be Col column
Interval time metric day,week,month,quarter or year















Odoo View operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.