Odoo Wizards

Odoo Wizards

Wizards describe interactive sessions with the user (or dialog boxes) through dynamic forms. A wizard is simply a model that extends the class TransientModel instead of Model. The class TransientModel extends Model and reuse all its existing mechanisms, with the following particularities:

  • Wizard records are not meant to be persistent; they are automatically deleted from the database after a certain time. This is why they are called transient.
  • Wizard models do not require explicit access rights: users have all permissions on wizard records.
  • Wizard records may refer to regular records or wizard records through many2one fields, but regular records cannot refer to wizard records through a many2one field.

We want to create a wizard that allow users to create attendees for a particular session, or for a list of sessions at once.

Wizard 可以通过 dynamic form 给 user 提供 交互式的sessions,a warzard 就是一个简单的model,继承自TransientModel ,而不是普通的Model, class TransientModel 也是继承自 Model, 拥有Model的所有特性,但是多出如下几点:

  • Wizard record 不是固定的,他们将会在一定时间后,就被从database中删除掉,所以叫做 Transient
  • Wizard models 是不需要给它设置权限的,因为任意用户都拥有它的所有权限
  • Wizard records 可能会用到 many2one 连接到 普通的 record,但是普通的 record 是不能通过 many2one 连接到 wizard records

我们将要创建一个wizard,使得我们可以对 一个或多个 session ,一次性选择好他们的 attendees。


Launching wizards

Wizards are launched by ir.actions.act_window records, with the field target set to the value new. The latter opens the wizard view into a popup window. The action may be triggered by a menu item.

There is another way to launch the wizard: using an ir.actions.act_window record like above, but with an extra field src_modelthat specifies in the context of which model the action is available. The wizard will appear in the contextual actions of the model, above the main view. Because of some internal hooks in the ORM, such an action is declared in XML with the tag act_window.

<act_window id="launch_the_wizard"
            name="Launch the Wizard"
            src_model="context_model_name"
            res_model="wizard_model_name"
            view_mode="form"
            target="new"
            key2="client_action_multi"/>

Wizards use regular views and their buttons may use the attribute special="cancel" to close the wizard window without saving.



Wizards 是通过  ir.actions.act_window  被调用,在这个action中设置 field  target  为 new,这样设置之后,通过menu点击触发action,将会打开一个新的窗口。 


还有另一种方式开启wizard,在 ir.actions.act_window 中添加 field src_model, 指定特定的model才能调用action,The wizard will appear in the contextual actions of the model, above the main view. Because of some internal hooks in the ORM, such an action is declared in XML with the tag act_window.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值