class BookModel(models.Model):
_name = 'books.model'
_rec_name = 'book_Name'
"""attributes to store the details of book"""
book_Id = fields.Char(string='Book ID')
book_Name = fields.Char(string="Book Name")
authors = fields.Char(string="Authors")
genres = fields.Char(string="Genres")
book_Image = fields.Binary("Image")
book_Availability = fields.Selection([('available', 'Available'),
('not available', 'Not Available')],string="Status")
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
1222
Views
Hi,
For this, you have to create two models. One is for Book records and the other one for its copies.
class BooksBooks(models.Model):
_name = 'books.books'
_rec_name = 'book_Name'
book_id = fields.Char(string='Book ID')
book_Name = fields.Char(string="Book Name")
Then for the copies, you have to create another model
class BookCopies(models.Model):
_name = 'books.copies'
book_id = fields.Many2one('books.books', string='Book ID')
copy_no = fields.Char(string="Copy ID")
and make the field copy_no as unique by giving constrains.
Thanks
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up