Search code examples
javascriptodooodoo-8odoo-9odoo-10

Odoo - Auto close wizard and refresh parent


I created a normal view for a class in my module. Now i wanted to show that same view in another class on a button click . I have done that but the issue i am facing is that when that popup open it gives two buttons Save and Discard. Once i click save i should auto close and it should also refresh the parent view from which it was loaded. Is this possible in Odoo?

Beside this how can i create a javascript file in Odoo. I visited official documentation but i was unable to understand that do we have a javascript file against each class or against each module and how to create that and what are the things i can do in that javscript file. Basically i am asking for a well documentation for better understanding.

Edit : This is my button click function

@api.multi
def add_deposit_action(self):
    return {
            "type": "ir.actions.act_window",
            "name": 'Add A Deposit',
            "res_model": "amgl.order",
            "views": [[False, "form"]],
            "context": {'customer_id': self.id,
                        'account_number': self.account_number,
                        'date_opened': self.date_opened,
                        'account_type': self.account_type},
            'target': 'new',
            'is_deposit': True
        }

Solution

  • I visited official documentation but i was unable to understand that do we have a javascript file against each class or against each module and how to create that and what are the things i can do in that javscript file. Basically i am asking for a well documentation for better understanding.

    The official documentation of Odoo is here: https://www.odoo.com/documentation/master/. It's quite good to getting to know Odoo and see, how to use the interface. But it could be difficult to find the answer for your technical question there.

    Another better way is to create your question inside the forum here: https://www.odoo.com/de_DE/forum/hilfe-1

    For me, i have learned a lot from this book: Odoo Development Cookbook. You can try to have a look on this book, if you would like to do more development with Odoo.


    I have done that but the issue i am facing is that when that popup open it gives two buttons Save and Discard. Once i click save i should auto close and it should also refresh the parent view from which it was loaded. Is this possible in Odoo?

    Yes, it's possible. To reload the parent view (original view), you need to return the tag reload in the function, which is called by the button Save in your popup.

    For example:

    def function():
       # do something here
       return {
            'type': 'ir.actions.client',
            'tag': 'reload',
       }