Forráskód Böngészése

Merge branch 'dev'

Yu Yang 1 éve
szülő
commit
3bd0d6f9cc

+ 1 - 0
my_library/__init__.py

@@ -0,0 +1 @@
+from . import models

+ 15 - 0
my_library/__manifest__.py

@@ -0,0 +1,15 @@
+{
+    'name': "My library",
+    'summary': "Manage books easily",
+    'description': """Long description""",
+    'author': "YU",
+    'website': "https://www.qidian.com/",
+    'category': 'Uncategorized',
+    'version': '13.0',
+    'depends': ['base'],
+    'data': [
+        'views/library_book.xml'
+    ],
+    'application': True,
+    'installable': True,
+}

+ 0 - 0
my_library/controllers/__init__.py


+ 1 - 0
my_library/models/__init__.py

@@ -0,0 +1 @@
+from . import library_book

+ 11 - 0
my_library/models/library_book.py

@@ -0,0 +1,11 @@
+from odoo import models, fields
+
+
+class LibraryBook(models.Model):
+    _name = 'library.book'
+    name = fields.Char('Title', required=True)
+    date_release = fields.Date('Release Date')
+    author_ids = fields.Many2many(
+        'res.partner',
+        string='Authors'
+    )

+ 38 - 0
my_library/views/library_book.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+    <!-- Data records go here -->
+    <record id='library_book_action'
+            model='ir.actions.act_window'>
+        <field name="name">Library Books</field>
+        <field name="res_model">library.book</field>
+        <field name="view_mode">form</field>
+        <field name="view_mode">tree,form</field>
+    </record>
+    <menuitem name="My Library" id="libray_base_menu"/>
+    <menuitem name="Books" id="library_book_menu"
+              parent="libray_base_menu" action="library_book_action"/>
+
+    <record id="library_book_view_tree" model="ir.ui.view">
+        <field name="name">Libray 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>
+    <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 Author"
+                        name="withou_author"
+                        domain="[{'author_ids', '=', False}]"/>
+            </search>
+        </field>
+    </record>
+</odoo>