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.

0

How to automatically search on a many2one field?

By
Alex Malone
on 4/15/13, 8:39 AM 3,061 views

Hi folks,

So, I have an entity in my system called "Calendar Events". This entity has a field called "case_id" defined as follows:

'case_id': fields.many2one('jcrm.case','Linked Case'),

From my case entity, I have a button on the form view that takes the user from cases to events and tries to filter the events by the case_id.

Search view definition for case_id on event search screen (verified working when manually typing in a case):

<field name="case_id" filter_domain="[('case_id','ilike',self)]" />

Definition of the actions attached to my button:

<record id="action_case_calendar_event_list" model="ir.actions.act_window">
        <field name="name">Case Events</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">jcrm.calendar.event</field>
        <field name="src_model">jcrm.case</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="context">{'search_default_case_id': active_id}</field>
        <field name="domain">[]</field>
        <field name="search_view_id" ref="jcrm_calendar.view_jcrm_calendar_event_search"/>
    </record>

It is the context which is "broken" here. In version 6, the 'search_default_case_id': active_id, would basically automatically fill in the case_id search field with the ID of the case I am coming from. In version 7, this doesn't work.

I wondered if the problem was the "active_id" bit so I hard coded an ID, that didn't work.

I wondered if the terminology didn't work anymore, so I tried a different field type ('search_default_name': 'Alex') and that did work, so it seems my terminology is correct.

So, I was wondering if anyone could help me out?

1

Stefan Reisich

--Stefan Reisich--
831
| 7 7 8
Pfungstadt, Germany
--Stefan Reisich--
Stefan Reisich
On 4/16/13, 2:13 PM

maybe you have the same problem like i had:

https://accounts.openerp.com/forum/Help-1/question/8598/

look my answer, maybe that is the solution for you too.

Hi there, thanks for your response but unfortunately it looks like the fix either hasn't been released or doesn't work as I am still experiencing the issue despite updating my server and web code. Thanks for pointing me in the right direction though.

Alex Malone
on 4/25/13, 10:24 AM

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: 4/15/13, 8:39 AM
Seen: 3061 times
Last updated: 3/16/15, 8:10 AM