Skip to Main Content
Odoo 12 Development Cookbook - Third Edition
book

Odoo 12 Development Cookbook - Third Edition

by Parth Gajjar, Alexandre Fayolle, Holger Brunn, Daniel Reis
April 2019
Beginner to intermediate content levelBeginner to intermediate
774 pages
24h 59m
English
Packt Publishing
Content preview from Odoo 12 Development Cookbook - Third Edition

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:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Odoo 11 Development Cookbook - Second Edition - Second Edition

Odoo 11 Development Cookbook - Second Edition - Second Edition

Alexandre Fayolle, Holger Brunn
Odoo 14 Development Cookbook - Fourth Edition

Odoo 14 Development Cookbook - Fourth Edition

Parth Gajjar, Alexandre Fayolle, Holger Brunn, Daniel Reis

Publisher Resources

ISBN: 9781789618921Supplemental Content