How to do it...

Follow these steps to add a new view called m2m_group:

  1. Add a new view type in ir.ui.view:
class View(models.Model):    _inherit = 'ir.ui.view'    type = fields.Selection(selection_add=[('m2m_group', 'M2m Group')])
  1. Add a new view mode in ir.actions.act_window.view:
class ActWindowView(models.Model):    _inherit = 'ir.actions.act_window.view'    view_mode = fields.Selection(selection_add=[('m2m_group', 'M2m group')])
  1. Add a new method by inheriting from the base model. This method will be called from the JavaScript model (see step 4 for more details):
class Base(models.AbstractModel):    _inherit = 'base'    @api.model    def get_m2m_group_data(self, domain, m2m_field):        records = self.search(domain)        result_dict = {}        for record in records:

Get Odoo 12 Development Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.