Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
17112 Переглядів

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.

Аватар
Відмінити
Найкраща відповідь

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'}" />;


Аватар
Відмінити
Найкраща відповідь

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"/>
Аватар
Відмінити