How to do it...

Follow the steps below to enable workflows, like kanban for the book rent model.

  1. Add a kanban view for libary.book.rent, as follows:
<record id="library_book_rent_view_kanban" model="ir.ui.view">
<field name="name">Rent Kanban</field>
<field name="model">library.book.rent</field>
<field name="arch" type="xml">
<kanban default_group_by="stage_id">
<field name="stage_id" />
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click">
<div class="oe_kanban_content">
<div class="oe_kanban_card">
<div>
<i class="fa fa-user"/>
<b>
<field name="borrower_id" />
</b>
</div>
<div class="text-muted">
<i class="fa fa-book"/>
<field name="book_id" />
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
  1. Add kanban in the library_book_rent_action action, as follows:
...
<field name="view_mode">kanban,tree,form</field>
...
  1. Add the _group_expand_stages() method and the group_expand attribute in the stage_id field, as follows:
@api.model
def _group_expand_stages(self, stages, domain, order):
return stages.search([], order=order)

stage_id = fields.Many2one(
'library.rent.stage',
default=_default_rent_stage,
group_expand='_group_expand_stages'
)

Restart the server and update the module to apply the changes. This will enable a kanban board, as shown in the following image:

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

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