Follow these steps to add a new view called m2m_group:
- 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')])
- 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')])
- 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: