Skip to Content
Odoo Development Cookbook
book

Odoo Development Cookbook

by Holger Brunn, Alexandre Fayolle, Daniel Reis
April 2016
Beginner to intermediate content levelBeginner to intermediate
400 pages
9h 16m
English
Packt Publishing
Content preview from Odoo Development Cookbook

Customizing how records are searched

The Defining the Model representation and order recipe in Chapter 3, Creating Odoo Modules introduced the name_get() method, which is used to compute a representation of the record in various places, including in the widget used to display Many2one relations in the web client.

This recipe shows how to allow searching for a book in the Many2one widget by title, author, or ISBN by redefining name_search.

Getting ready

For this recipe, we will be using the following model definition:

class LibraryBook(models.Model): _name = 'library.book' name = fields.Char('Title') isbn = fields.Char('ISBN') author_ids = fields.Many2many('res.partner', 'Authors') @api.model def name_get(self): result = [] for book in self: authors ...
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 Development Cookbook - Fifth Edition

Odoo Development Cookbook - Fifth Edition

Husen Daudi, Jay Vora, Parth Gajjar, Alexandre Fayolle, Holger Brunn, Daniel Reis
Odoo 14 Development Cookbook - Fourth Edition

Odoo 14 Development Cookbook - Fourth Edition

Parth Gajjar, Alexandre Fayolle, Holger Brunn, Daniel Reis
Odoo 12 Development Cookbook - Third Edition

Odoo 12 Development Cookbook - Third Edition

Parth Gajjar, Alexandre Fayolle, Holger Brunn, Daniel Reis

Publisher Resources

ISBN: 9781785883644Supplemental Content