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

invisible elements on button click

By
Shaumyadeep Chaudhuri
on 10/7/13, 5:48 AM 1,695 views

Hi, I need to make hide some elements on a button click. How can i do that? currently i tried using 2 functional fields and a character field which doesn't seem to work. here is the xml snippet of what i'm trying to hide.

<sheet attrs="{'invisible':[('historical_concept','=','True')]}">.......</sheet>

and here's the python code

def _historical_concept(self,cr,uid,ids,field_name,argus,context):
    ret_val={}
    for record in self.browse(cr,uid,ids,context):
        if (record.historical_state is not False and record.historical_state == 'concept') or record.state in ['concept']:
            self.write(cr,uid,ids,{'historical_state':None})
            ret_val[record.id]=False
        else:
            ret_val[record.id]=True
    return ret_val

def historical_stage_concept(self,cr,uid,ids,context=None):
    return self.write(cr,uid,ids,{'historical_state':'concept'})

EDIT 1: Button code

<button name="historical_stage_concept" type="object"/>

EDIT 2: _coloumns and _defaults _column is too long so i paste only the relevant part if more is needed please ask.

_columns = {
             'state':fields.selection([
                                     ('concept', 'Concept'),
                                     ('develop', 'Develop'),
                                     ('market', 'Market'),
                                     ('refuse','Rejected')],
                                    'Stage', readonly=True), 
            'historical_state':fields.char(),
            'historical_concept':fields.function(_historical_concept, type='boolean', method=True, string='Historical Concept'),
            'historical_develop':fields.function(_historical_develop, type='boolean', method=True, string='Historical Develop'),
            }

_defaults = {
           'historical_state':None
           }

What does the button do? can you paste its XML line.

IBS
on 10/7/13, 11:40 AM

The button is just a button at the moment, i tried to make it an object and hence the python code above but that didn't work. My primary goal is making something invisible or visible on the button click but there are more than one buttons and the invisibility or visibility should not be stored to the database. those are the only requirements and doesn't matter how they are implemented

Shaumyadeep Chaudhuri
on 10/7/13, 11:56 AM

Can you paste the _columns declaration of your model.

IBS
on 10/7/13, 11:59 AM

i just pasted what i felt was relevant since the full thing is too long

Shaumyadeep Chaudhuri
on 10/7/13, 12:07 PM

I don't think that this can be done with some python code, you have to write a JS file to do it.

GH Mediacloud, Grover Menacho
on 10/7/13, 12:29 PM
0

IBS

--IBS--
1302
| 4 5 8
Tétouan, Morocco
--IBS--

For more informations about IBS, please visit our website at www.ibs-na.com.

For a specific questions, collaboration or help, please send us an email to support@ibs-na.com

IBS
On 10/7/13, 1:12 PM

These are the changes you must do :

if record.historical_state == 'concept':

and

<!-- The quotes are removed -->
<sheet attrs="{'invisible':[('historical_concept','=',True)]}">.......</sheet>

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

1 follower(s)

Stats

Asked: 10/7/13, 5:48 AM
Seen: 1695 times
Last updated: 3/16/15, 8:10 AM