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

Hide/show urls in form view

By
Ramy Wafa
on 4/23/14, 4:59 PM 1,491 views

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.

1

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 4/23/14, 6:18 PM

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>

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>

Ramy Wafa
on 4/26/14, 2:44 PM

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

Prakash
on 4/29/14, 3:21 AM

Thank you very much really great help

Ramy Wafa
on 4/29/14, 12:48 PM

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/23/14, 4:59 PM
Seen: 1491 times
Last updated: 3/16/15, 8:10 AM