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.