-
Notifications
You must be signed in to change notification settings - Fork 74
Updated #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Updated #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "name": "Library Extensions", | ||
| "version": "1.0" | ||
| "depends": ["library"], | ||
| "author": " Your Name", | ||
| "category": "Library", | ||
| "data": [ | ||
| "views/library_book_views.xml", | ||
| ], | ||
| "installable": True, | ||
| "application": False, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import library_book |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from odoo import models, fields, api | ||
|
|
||
| class LibraryBook(models.Model): | ||
| _inherit = "library.book" | ||
|
|
||
| author_id = fields.Many2one( | ||
| comodel_name = "res.partner", | ||
| string = "Author" | ||
| required = True | ||
| ) | ||
|
|
||
| class LibraryBookCategory(models.Model): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this to another python file called |
||
| _name = "library.book.category" | ||
| _description = "Book Category" | ||
|
|
||
| name = fields.Char(string="Category Name", required=True, unique=True) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| class LibraryBook(models.Model): | ||
| _inherit = "library.book" | ||
|
|
||
| category_id = fields.Many2many( | ||
| comodel_name = "library.book.category", | ||
| string = "Categories" | ||
| ) | ||
|
Comment on lines
+18
to
+24
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to create another model declaration for a new field, just put it under on the original model delaration. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <odoo> | ||
| <!-- Book Form View --> | ||
| <record id="view_library_book_form_inherit" model="ir.ui.view"> | ||
| <field name="name">library.book.form.inherit</field> | ||
| <field name="model">library.book</field> | ||
| <field name="inherit_id" ref="library.view_library_book_form"/> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong inherit ID |
||
| <field name="arch" type="xml"> | ||
| <xpath expr="//field[@name='name']" position="after"> | ||
| <field name="author_id"/> | ||
| <field name="category_id"/> | ||
| </xpath> | ||
| </field> | ||
| </record> | ||
|
|
||
| <!-- Book List View --> | ||
| <record id="view_library_book_tree_inherit" model="ir.ui.view"> | ||
| <field name="name">library.book.tree.inherit</field> | ||
| <field name="model">library.book</field> | ||
| <field name="inherit_id" ref="library.view_library_book_tree"/> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong inherit ID |
||
| <field name="arch" type="xml"> | ||
| <xpath expr="//tree/field[@name='name']" position="after"> | ||
| <field name="author_id"/> | ||
| <field name="category_id"/> | ||
| </xpath> | ||
| </field> | ||
| </record> | ||
|
|
||
| <!-- Book Category List View --> | ||
| <record id="view_library_book_category_tree" model="ir.ui.view"> | ||
| <field name="name">library.book.category.tree</field> | ||
| <field name="model">library.book.category</field> | ||
| <field name="arch" type="xml"> | ||
| <tree> | ||
| <field name="name"/> | ||
| </tree> | ||
| </field> | ||
| </record> | ||
|
|
||
| <!-- Book Category Form View --> | ||
| <record id="view_library_book_category_form" model="ir.ui.view"> | ||
| <field name="name">library.book.category.form</field> | ||
| <field name="model">library.book.category</field> | ||
| <field name="arch" type="xml"> | ||
| <form> | ||
| <sheet> | ||
| <group> | ||
| <field name="name"/> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
Comment on lines
+29
to
+52
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this views to a new file |
||
|
|
||
| <!-- Menu Item for Book Categories --> | ||
| <menuitem id="menu_library_book_category" name="Book Category" parent="library.menu_library_root"/> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a view action for this menuitem, wrong parent is used for this menu item. Move this views to a new file library_book_category_views.xml |
||
| </odoo> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put your name as the Author