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.

1

Passing domain from button -> action -> search view

By
Calvin Prasad
on 6/27/13, 10:19 AM 2,285 views

Hi All,

I have a button as follows:

<button string="View Cancelled Applications" name="%(action_recruit_application)d" type="action" domain="[('state','=','cancel')]"/>

The action is as follows:

  <record model="ir.actions.act_window" id="action_recruit_application">
    <field name="name">Applications</field>
    <field name="res_model">recruit.application</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
    <field name="search_view_id" ref="view_recruit_application_search"/>
</record>

Finally the search view is as follows:

    <record model="ir.ui.view" id="view_recruit_application_search">
    <field name="name">recruit.application.search</field>
    <field name="model">recruit.application</field>
    <field name="arch" type="xml">
        <search string="Applications">
            <field name="application_id"/>
            <field name="name"/>     
            <field name="application_date"/>
            <field name="state"/>
        </search>
    </field>
</record>

I can't seem to pass the 'state' = 'cancel' to the search view.

Could anyone please help me out?

Thanks in advance.

0
kirubanidhi
On 6/16/16, 3:03 AM

Button use trigger window action,

In this below code is working for me,

String -> Displayed name from UI

Name->%( model_name.action_id)d

Type->Action or object 

style-> We can set background in my need color

Context->The context is a dictionary carrying session data to be used by client-side views and by server processes. It can transport information from one view to another, or to the server-side logic. It is frequently used in window actions and relational fields to send information to the views opened through them.

Odoo sets some basic information about the current session on the context. The initial session information can look like this:

{'lang': 'en_US', 'tz': 'Europe/Brussels', 'uid': 1}


<button string="Train Action"  name="%(train.reservation_action_window)d" context="{'search_default_state': 'cancel'} style="background-color:red"  type="action" class="oe_highlight"  icon="fa-bus"/>
0

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 10/4/15, 1:45 AM

Hi,

Instead of passing it by domain, try by using context.

Please try like this:

<button string="View Cancelled Applications" name="%(action_recruit_application)d" type="action" context="{'search_default_state': 'cancel'}" />;


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/27/13, 10:19 AM
Seen: 2285 times
Last updated: 6/16/16, 3:03 AM