Odoo Help

1

Passing domain from button -> action -> search view

By
Calvin Prasad
on 6/27/13, 10:19 AM 3,581 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
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'}" />;


About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 6/27/13, 10:19 AM
Seen: 3581 times
Last updated: 6/16/16, 3:03 AM