This question has been flagged
2 Replies
3000 Views

I want to know that if its possible to set the visibility of a form's button based on how this form is being called. Like there are two forms 'A' and 'B'. Now the button on form 'A' calls the form 'B'. All I want to show the form 'B' button only if its called through that specific form 'A' button. I dont know how this will be achievable but I think I will have to set the attributes on the button of form B. But how to check if form A button is clicked. Thats where I am stuck. I need some guidance on this.Every help will be appreciated. I tired with this on form 'A':

def edits(self,cr,uid,ids,context=None): for id in ids: 

      deg_obj=self.pool.get('deg.form').browse(cr,uid,id)

      my_id=int(deg_obj.my_products)

      return{ 'view_type': 'form',

                  'view_mode': 'form',

                  'res_model': 'product.product',

                  'res_id':my_id,

                  'type': 'ir.actions.act_window',

                  'nodestroy':False,

                  'target': 'inline', }

And this in xml on form 'B':

 <button name="saves" string="SAVE" type="object"  invisible="context.get('product1')" />

 

Avatar
Discard
Author Best Answer

Ups, I forget the comma : "context.get('product1', False)"

Avatar
Discard
Author

Thanks a lot, it saved the day

Best Answer

I think you can add new pair of context in the form A. Then check the context from form B.

Avatar
Discard
Author

PLz check the updated code above. I tried this but the button is not shown when I go from edit button and its shown if I go from any where else. Plz help

Before further coding, you can test the following method. Define context for form A in Edit Action (Developer Mode), like {product1: True}. Then call form B.

Author

i tried this. and i can see the value of context i am sending from form A. but still not sure what i am missing as button shows both ways. whether you come from form A or elsewhere

in form B : "context.get('product1' False)"