Getting ready

For this recipe, we will be using the my_library module from the previous recipe. We will need a new model to store issues submitted by users.

So, before starting this recipe, modify the previous code. Add a field in the library.book model and new book.issues model, as follows:

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')
image = fields.Binary(attachment=True)
html_description = fields.Html()
book_issue_id = fields.One2many('book.issue', 'book_id')


class LibraryBookIssues(models.Model):
_name = 'book.issue'

book_id = fields.Many2one('library.book', required=True)
submitted_by = fields.Many2one('res.users')
isuue_description = fields.Text()

Add a book_issues_id field in the book form view, as follows:

...
<group string="Book Issues">
<field name="book_issue_id" nolabel="1">
<tree>
<field name="create_date"/>
<field name="submitted_by"/>
<field name="isuue_description"/>
</tree>
</field>
</group>
...

Add access rights for the new book.issue model in the ir.model.access.csv file, as follows:

acl_book_issues,library.book_issue,model_book_issue,group_librarian,1,1,1,1

We have added a new model for the book issues, and now, we will add a new template with an HTML form.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset