Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
8352 Zobrazení

I am trying to put a link to download docs files in form view. I already have the links and I made a custom web controller that actually does the download but the problem is that they present in every part of the view. I want it to appear based on specific condition where the state field of an applicant is set to a specific value similar to buttons in form view.

Bellow is an example of a button that appears based on the state condition:

<button name="action_open_agreement_form" type="object" string="P020 Declaration and undertaking" attrs="{'invisible':[('state','!=','done')]}"/>

this allows me to show a button if the state of the applicant is not done.

The link I have is as bellow in the xml

<record model="ir.ui.view" id="view_sefarer_applicant_form">
    <field name="name">Jobs - Recruitment Form</field>
<field name="model">seafarer.applicant</field>
<field name="arch" type="xml">
    <form string="Jobs - Recruitment Form" version="7.0">
        ...
        <sheet>
            ......
    <div class="oe_right oe_button_box">
                ....
                <a href="#" onclick="window.open('/sc/some_html?id=P014-'+$('.seafarer_id span').text(), '_blank')" class="applicant_docs_forms"  id="P014">P014 Drug/Alcohol Delcaration</a>
                .....
            </div>
        </sheet>
     .....

I need to use something like attrs but it is not working, I also tried to use javascript with on window load or document ready but that's not working too. I also tried desperate things like having a button with attrs with the condition and having a onclick action on it that clicks the link and having the link hidden but that didn't work as well.

I am pretty desperate and any help would be appreciated.

Avatar
Zrušit
Nejlepší odpověď

please check in the xml file state field is available before the button. If not add the same.

Example attrs tag in button:-

<field name="state" invisible="1"/>
<button name="action_open_agreement_form" type="object" string="P020 Declaration and undertaking" attrs="{'invisible':[('state','!=','done')]}"/>

Example attrs tag in link:

<group  attrs="{'invisible':[('state','!=','done')]}">
 <a href="#" onclick="window.open('/sc/some_html?id=P014-'+$('.seafarer_id span').text(), '_blank')" class="applicant_docs_forms" id="P014">P014 Drug/Alcohol Delcaration</a>
</group>
Avatar
Zrušit
Autor

thank you but I want the attrs attribute on the link not on the button itself, so I need sth like: <a href="#" onclick="window.open('/sc/some_html?id=P014-'+$('.seafarer_id span').text(), '_blank')" class="applicant_docs_forms" id="P014" attrs="{'invisible':[('state','!=','done')]}">P014 Drug/Alcohol Delcaration</a>

I updated the answer try attrs tag to add in the group.

Autor

Thank you very much really great help

Related Posts Odpovědi Zobrazení Aktivita
0
bře 15
4105
0
bře 15
3455
0
čvc 15
7790
0
bře 15
4363
1
bře 15
272