Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
9553 Представления

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.

Автор

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

Can you paste the _columns declaration of your model.

Автор

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

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

Лучший ответ

These are the changes you must do :

if record.historical_state == 'concept':

and

<!-- The quotes are removed -->
<sheet attrs="{'invisible':[('historical_concept','=',True)]}">.......</sheet>
Аватар
Отменить
Related Posts Ответы Просмотры Активность
3
мар. 15
5987
1
мар. 15
4334
1
мая 22
26245
Form Sheet width Решено
8
мая 16
34014
1
мар. 15
17908