Getting ready

You need to know the structure of the models for which you want to create a record, especially their names and types, as well as any constraints that exist on these fields (for example, whether some of them are mandatory). For this recipe, we will reuse the my_library module from Chapter 5, Application Models. Take a look at the following example to quickly recall the library.book.category model:

class BookCategory(models.Model):
_name = 'library.book.category'

name = fields.Char('Category')
description = fields.Text('Description')
parent_id = fields.Many2one(
'library.book.category',
string='Parent Category',
ondelete='restrict',
index=True
)
child_ids = fields.One2many(
'library.book.category', 'parent_id',
string='Child Categories')
..................Content has been hidden....................

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