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

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

By
arsalan
on 8/15/14, 1:23 AM 665 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')" />

 

0
arsalan
On 8/15/14, 7:41 AM

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

Thanks a lot, it saved the day

arsalan
on 8/15/14, 7:49 AM
3

Ben Bernard

--Ben Bernard--
1083
| 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

arsalan
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

arsalan
on 8/15/14, 6:38 AM

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

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

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: 8/15/14, 1:23 AM
Seen: 665 times
Last updated: 3/16/15, 8:10 AM