Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python-envs.defaultEnvManager": "ms-python.python:system",
"python-envs.pythonProjects": []
}
49 changes: 12 additions & 37 deletions addons_library/library/models/library_book.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,19 @@
# -*- coding: utf-8 -*-

from odoo import models, fields, api

from odoo import models, fields

class LibraryBook(models.Model):
######################
# Private attributes #
######################
_name = "library.book"
_description = "Book"
_order = "name"

###################
# Default methods #
###################
name = fields.Char(string="Name",
required=True)
isbn_13 = fields.Char(string="ISBN 13",
required=True)

######################
# Fields declaration #
######################

##############################
# Compute and search methods #
##############################

############################
# Constrains and onchanges #
############################

#########################
# CRUD method overrides #
#########################

##################
# Action methods #
##################

####################
# Business methods #
####################
name = fields.Char(string="Name", required=True)
isbn_13 = fields.Char(string="ISBN 13", required=True)
author_id = fields.Many2one(
'res.partner',
string='Author',
domain=[('is_company', '=', False)]
)
category_id = fields.Many2one(
'library.book.category',
string='Category'
)
4 changes: 4 additions & 0 deletions addons_library/library_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-

from . import models

14 changes: 14 additions & 0 deletions addons_library/library_extensions/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
'name': 'Library Extensions',
'version': '1.0',
'author': 'Your Name',
'depends': ['library', 'contacts'],
'data': [
'security/ir.model.access.csv',
'views/library_book_views.xml',
'views/library_book_category_views.xml',
],

'installable': True,
'application': False,
}
6 changes: 6 additions & 0 deletions addons_library/library_extensions/config/odoo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[options]
addons_path = /mnt/addons_library
data_dir = /var/lib/odoo
proxy_mode = True
admin_passwd = $pbkdf2-sha512$600000$WCuF8B6DcC5lTInRWusdYw$EK.4CpFjAl2yFIDWRxz1sE/KXQ2oHh7m5YqIDaRO7WGxGlcTNNN5Z4UW1/qO8ms/XzHAlMfDvuUifhXu03MS.g

2 changes: 2 additions & 0 deletions addons_library/library_extensions/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import library_book_category
from . import library_book_inherit
14 changes: 14 additions & 0 deletions addons_library/library_extensions/models/library_book_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import ValidationError

class LibraryBookCategory(models.Model):
_name = "library.book.category"
_description = "Book Category"
_order = "name"

name = fields.Char(string="Category Name", required=True)

_sql_constraints = [
('unique_category_name', 'unique(name)', 'Category name must be unique!')
]
14 changes: 14 additions & 0 deletions addons_library/library_extensions/models/library_book_inherit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from odoo import models, fields

class LibraryBook(models.Model):
_inherit = 'library.book'

author_id = fields.Many2one(
'res.partner',
string='Author'
)

category_id = fields.Many2many(
'library.book.category',
string='Categories'
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_library_book_category,access.library.book.category,model_library_book_category,,1,1,1,1
11 changes: 11 additions & 0 deletions addons_library/library_extensions/views/library_book_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo import models, fields

class LibraryBookCategory(models.Model):
_name = 'library.book.category'
_description = 'Book Category'

name = fields.Char(string='Category Name', required=True)

_sql_constraints = [
('unique_name', 'unique(name)', 'Category name must be unique!')
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Tree 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 string="Book Categories">
<field name="name"/>
</tree>
</field>
</record>

<!-- 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 string="Book Category">
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>

<!-- Action -->
<record id="action_library_book_category" model="ir.actions.act_window">
<field name="name">Book Categories</field>
<field name="res_model">library.book.category</field>
<field name="view_mode">tree,form</field>
</record>

<!-- Menu Item -->
<menuitem
id="menu_library_book_category"
name="Book Categories"
action="action_library_book_category"
sequence="5"/>
</odoo>
48 changes: 48 additions & 0 deletions addons_library/library_extensions/views/library_book_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Tree View for Books -->
<record id="view_library_book_tree" model="ir.ui.view">
<field name="name">library.book.tree</field>
<field name="model">library.book</field>
<field name="arch" type="xml">
<tree string="Books">
<field name="name"/>
<field name="author_id"/>
<field name="category_id"/>
<field name="isbn_13"/>
</tree>
</field>
</record>

<!-- Form View for Books -->
<record id="view_library_book_form" model="ir.ui.view">
<field name="name">library.book.form</field>
<field name="model">library.book</field>
<field name="arch" type="xml">
<form string="Book">
<sheet>
<group>
<field name="name"/>
<field name="author_id"/>
<field name="category_id"/>
<field name="isbn_13"/>
</group>
</sheet>
</form>
</field>
</record>

<!-- Action for Books -->
<record id="action_library_book" model="ir.actions.act_window">
<field name="name">Books</field>
<field name="res_model">library.book</field>
<field name="view_mode">tree,form</field>
</record>

<!-- Menu Item -->
<menuitem
id="menu_library_book"
name="Books"
action="action_library_book"
sequence="1"/>
</odoo>
8 changes: 8 additions & 0 deletions addons_library/library_extensions/views/library_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem
id="library_menu_main"
name="Library"
sequence="5"
web_icon="library,static/description/icon.png"/>
</odoo>
1 change: 1 addition & 0 deletions config/odoo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
addons_path = /mnt/addons_library
data_dir = /var/lib/odoo
proxy_mode = True
admin_passwd = $pbkdf2-sha512$600000$WCuF8B6DcC5lTInRWusdYw$EK.4CpFjAl2yFIDWRxz1sE/KXQ2oHh7m5YqIDaRO7WGxGlcTNNN5Z4UW1/qO8ms/XzHAlMfDvuUifhXu03MS.g