Odoo Help


How to show form button if the form is directed through specific button ?

on 8/15/14, 1:23 AM 1,056 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: 



      return{ 'view_type': 'form',

                  'view_mode': 'form',

                  'res_model': 'product.product',


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


                  'target': 'inline', }

And this in xml on form 'B':

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


On 8/15/14, 7:41 AM

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

Thanks a lot, it saved the day

on 8/15/14, 7:49 AM

Ben Bernard

--Ben Bernard--

| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 8/15/14, 4:44 AM

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

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

on 8/15/14, 6:08 AM

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.

Ben Bernard
on 8/15/14, 6:20 AM

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

on 8/15/14, 6:38 AM

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

Ben Bernard
on 8/15/14, 6:45 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/15/14, 1:23 AM
Seen: 1056 times
Last updated: 3/16/15, 8:10 AM