Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

"Search More..." in many2one field

By
Jevgeni
on 6/6/13, 4:46 AM 3,505 views

How do I add "Search mode..." option to any many2one field? By selecting this option tree view opens up where I select one record.

I found similar example in Messaging model: 1. I select "Join a group" in "My Groups" category, 2. click "Create", 3. click the expand option for "Authorized Group" many2one list 4. There are listed "Create and Edit" and "Search More..." options. When I click "Search More" it opens up a search tree.

Please, how do I implement the same thing?

2

Hiral Patel (hip)

--Hiral Patel (hip)--
Tiny ERP Pvt Ltd
http://www.odoo.com
913
| 2 1 5
India
--Hiral Patel (hip)--


Hiral Patel (hip)
On 6/6/13, 5:20 AM

You have to create a many2one field like:

_columns = {
    'group_public_id': fields.many2one('res.groups', string='Authorized Group'),
}

Here res.groups is a relational table name.

And add this field to the form view in xml file and you can view the Search More.. option.

Ex:

<field name="group_public_id"/>

I have created a demo for you which may help you. Search More is displayed when there are at least 7 records in my.test1.

class my_test1(osv.osv): _name = 'my.test1' _columns = { 'name': fields.char('Test') }

class my_test(osv.osv): _name = 'my.test' _columns = { 'name': fields.char('Test'), 'test_id': fields.many2one('my.test1', string='Test Data'), }

Add following in xml file :

<record id="view_my_test_form" model="ir.ui.view"> <field name="name">my.test.form</field> <field name="model">my.test</field> <field name="arch" type="xml"> <form string="Product Form"> <field name="name"/> <field name="test_id"/> </form> </field> </record>

Thank you for your answer! :) I want to use my own many2one object than 'res.groups'.

e.g. class my_test(osv.osv): _name = 'my.test' _columns = {'name': fields.char('Test')} my_test()

Then how can I add "Search More" to this object? Thanks!

Jevgeni
on 6/6/13, 5:39 AM

Have you added search view for that model?

Shelton
on 6/6/13, 6:16 AM

No. Failed several times adding it before. What are the minimum requirements for search view?

Jevgeni
on 6/6/13, 6:29 AM

You have to create XML record same as VIEW for SEARH VIEW and assign that ID in "search_view_id" attribute in ACTION.

Dharmesh Rathod
on 6/6/13, 8:02 AM

You, sirs, are my heroes! I did not pay attention to this: "Search More is displayed when there are at least 7 records..."! Funnily enough, I spent 7 hours on this problem and all I had to do was add few more records! :)

Jevgeni
on 6/6/13, 8:41 AM
0
David Baramidze
On 8/14/16, 12:02 PM

I spent 7 hours on this problem and all I had to do was add few more records! <-- This is Answer. Thank you! you saved my 7 hours :))

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/6/13, 4:46 AM
Seen: 3505 times
Last updated: 8/14/16, 12:02 PM