Skip to Content
Menu
This question has been flagged
1 Reply
1222 Views
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")
Avatar
Discard
Best Answer

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

Avatar
Discard