Odoo - 自动关闭向导并刷新父级

Odoo - Auto close wizard and refresh parent

我在我的模块中为 class 创建了一个普通视图。现在我想在单击按钮时在另一个 class 中显示相同的视图。我已经这样做了,但我面临的问题是,当弹出窗口打开时,它会给出两个按钮 SaveDiscard。单击保存后,我应该自动关闭,它还应该刷新加载它的父视图。这在 Odoo 中可行吗?

除此之外,我如何在 Odoo 中创建 javascript 文件。我访问了官方文档,但我无法理解我们是否有针对每个 class 或每个模块的 javascript 文件以及如何创建它以及我可以在该 javscript 文件中做什么。基本上我要求一个很好的文档以便更好地理解。

编辑: 这是我的按钮点击功能

@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
        }

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.

Odoo 的官方文档在这里:https://www.odoo.com/documentation/master/。了解 Odoo 并了解如何使用界面非常好。但是在那里可能很难找到您的技术问题的答案。

另一种更好的方法是在此处的论坛中创建您的问题:https://www.odoo.com/de_DE/forum/hilfe-1

对我来说,我从这本书中学到了很多东西:Odoo Development Cookbook。如果你想用 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?

是的,这是可能的。要重新加载父视图(原始视图),您需要 return 函数中的标记 reload,它由 popup[= 中的按钮 Save 调用29=].

例如:

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