Redirecting the user

The method in step 2 does not return anything. This will cause the wizard dialog to be closed after the action is performed. Another possibility is to have the method return a dictionary with the fields of ir.action. In this case, the web client will process the action as if a menu entry had been clicked on by the user. The get_formview_action() method defined on the BaseModel class can be used to achieve this. For instance, if we wanted to display the form view of the member who has just borrowed the books, we could have written the following:

    def add_book_rents(self):
rentModel = self.env['library.book.rent']
for wiz in self:
for book in wiz.book_ids:
rentModel.create({
'borrower_id': wiz.borrower_id.id,
'book_id': book.id
}) members = self.mapped('borrower_id')
action = members.get_formview_action()
if len(borrowers.ids) > 1: action['domain'] = [('id', 'in', tuple(members.ids))]
action['view_mode'] = 'tree,form'
return action

This builds a list of members who have borrowed books from this wizard (in practice, there will only be one such member when the wizard is called from the user interface) and creates a dynamic action, which displays the members with the specified IDs.

The redirecting the user technique can be used to create a wizard which have several steps to be performed one after the other. Each step in the wizard can use the values of the previous steps. By providing a Next button that calls a method defined on the wizard which update some fields on the wizard, and return an action that will redisplay the same updated wizard and get ready for the next step.

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

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