markdown Odoo观点

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Odoo观点相关的知识,希望对你有一定的参考价值。

# Odoo view 
To add a view, we will add an XML file with its definition to the module. Since it is a new
Model, we must also add a menu option for the user to be able to access it.
Be aware that the sequence of the following steps is relevant, since some of them use
references to IDs defined in the preceding steps:
### 1. Create the XML file to add the data records describing the user interface
views/library_book.xml:
```
<?xml version="1.0" encoding="utf-8"?>
<odoo>
 <!-- Data records go here -->
</odoo>
```
### 2. Add the new data file to the addon module manifest, __manifest__.py by
adding it to views/library_book.xml:
```
{
 'name': "Library Books",
 'summary': "Manage your books",
 'depends': ['base'],
 'data': ['views/library_book.xml'],
}
```

### 3. Add the action that opens the Views in the library_book.xml file:
```
<act_window
 id="library_book_action"
 name="Library Books"
 res_model="library.book" />
```
### 4. Add the menu item to the library_book.xml file, making it visible to the users:
```
<menuitem
 id="library_book_menu"
 name="Library"
 action="library_book_action"
 parent=""
 sequence="5" />
```
**If you try and upgrade the module now, you should be able to see a new top menu option
(you might need to refresh your web browser).**

Clicking on it should work and will open
Views for Library Books that are automatically generated by the server:
### 5. Add a custom form view to the library_book.xml file:
```
<record id="library_book_view_form" model="ir.ui.view">
 <field name="name">Library Book Form</field>
 <field name="model">library.book</field>
 <field name="arch" type="xml">
 <form>
 <group>
 <field name="name"/>
 <field name="author_ids" widget="many2many_tags"/>
 </group>
 <group>
 <field name="date_release"/>
 </group>
 </form>
 </field>
</record>
```
### 6. Add a custom Tree (List) view to the library_book.xml file:
```
<record id="library_book_view_tree" model="ir.ui.view">
 <field name="name">Library Book List</field>
 <field name="model">library.book</field>
 <field name="arch" type="xml">
 <tree>
 <field name="name"/>
 <field name="date_release"/>
 </tree>
 </field>
</record>
```
### 7. Add custom Search options to the library_book.xml file:
```
<record id="library_book_view_search" model="ir.ui.view">
 <field name="name">Library Book Search</field>
 <field name="model">library.book</field>
 <field name="arch" type="xml">
 <search>
 <field name="name"/>
 <field name="author_ids"/>
 <filter string="No Authors" domain="[('author_ids','=',False)]"/>
 </search>
 </field>
</record>
```

以上是关于markdown Odoo观点的主要内容,如果未能解决你的问题,请参考以下文章

markdown Odoo pycharm设置

markdown Odoo sql fetch

markdown Odoo安装功能

markdown Odoo orm搜索

markdown Odoo数据库管理器

markdown Odoo cheatsheat