Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

手把手教你在7.0下开发wizard【多亏了总监指导,大家一起感谢他】



  • 首先,总监集耐心,爱心,雄心与一心;学富,财富,情妇与一身。
    气度非凡,气宇轩昂,气壮河山;英俊潇洒,英姿飒爽,英姿焕发。
    总监1岁会打字,3岁会编程,4岁满地跑,6岁单手抱电脑;
    10岁进微软,15开公司,18收谷歌,20成首富。
    看淡世间情与乱,屈身公司当总监。
    热心教导新来人,不求谢来不求钱。


    咳咳,说好的教程呢?写二楼好了,一楼赞总监



  • 整些没用的. 把最重要的教程搞丢了.



  • 首先,先安装前两个模块,即oecn_training与oecn_training_classroom
    oecn_training_classroom_wizard是基于oecn_training_classroom改写的,当然你也可以直接装oecn_training与oecn_training_classroom_wizard.zip!
    效果图见附件。
    wizard主要是定义一个osv_memory类,视图上加一个target,其他跟正常的view没啥区别。

    现在说下怎么基于oecn_training_classroom定义wizard
    首先,在oecn_training_classroom下写一个class,我是在classroom.py里写的。当然不一定写在同一个文件里。代码如下:

    # -*- coding: utf-8 -*-<br />from openerp.osv import fields, osv<br /> <br />class oecn_training_classroom(osv.osv):<br />&nbsp; &nbsp; _name = &#039;oecn.training.classroom&#039;<br />&nbsp; &nbsp; _description = u&#039;OECN 教室&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;number&#039;:fields.char(u&#039;编号&#039;, size=64, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;capacity&#039;:fields.integer(u&#039;容纳人数&#039;, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;location&#039;:fields.char(u&#039;地点&#039;, size=125, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;room_ids&#039;:fields.many2many(&#039;oecn.training.classroom.wizard&#039;, <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;classroom_many2many&#039;, <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;class_room_id&#039;,&#039;room_id&#039;,&nbsp; string=&#039;room&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />class oecn_training_classroom_wizard(osv.osv_memory):<br />&nbsp; &nbsp; _name = &#039;oecn.training.classroom.wizard&#039;<br />&nbsp; &nbsp; _description = u&#039;OECN 教室2&#039;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;p_number&#039;:fields.integer(u&#039;容纳人数&#039;, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;class_room_ids&#039;:fields.many2many(&#039;oecn.training.classroom&#039;, &#039;classroom_many2many&#039;, <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;room_id&#039;, &#039;class_room_id&#039;, string=&#039;room&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; def act_done(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp;  raise osv.except_osv(_(&#039;Error!&#039;), _(&#039;Set OK!&#039;))<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; <br />oecn_training_classroom()<br />oecn_training_classroom_wizard()<br />
    


    其中最关键的继承osv.osv_memory类

    xml里添加如下代码:

    &lt;!--定义表单视图--&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record model=&quot;ir.ui.view&quot; id=&quot;oecn_training_classroom_wizard_form_view&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;课程表单&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;type&quot;&gt;form&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;model&quot;&gt;oecn.training.classroom.wizard&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;form string=&quot;课程表单&quot; version=&quot;7.0&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button name=&quot;act_done&quot; string=&quot;Set It!&quot; type=&quot;object&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;p_number&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;class_room_ids&quot; widget=&quot;many2many_tags&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;!--定义列表视图--&gt;<br />&lt;!--定义视图动作--&gt;<br />&nbsp; &nbsp; &lt;record model=&quot;ir.actions.act_window&quot;&nbsp; id=&quot;action_oecn_training_classroom_wizard&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;课程&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;res_model&quot;&gt;oecn.training.classroom.wizard&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;view_type&quot;&gt;form&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;view_mode&quot;&gt;form,tree&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;view_id&quot; ref=&quot;oecn_training_classroom_wizard_form_view&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;target&quot;&gt;new&lt;/field&gt;<br />&nbsp; &nbsp; &lt;/record&gt;<br />&lt;!--定义菜单--&gt;<br />&nbsp; &nbsp; &lt;menuitem id=&quot;oecn_menu&quot; name=&quot;OECN&quot;/&gt;<br />&nbsp; &nbsp; &lt;menuitem id=&quot;oecn_training_menu&quot; name=&quot;OECN Training&quot; parent=&quot;oecn_menu&quot;/&gt;<br />&nbsp; &nbsp; &lt;menuitem id=&quot;oecn_training_classroom_wizard_menu2&quot; name=&quot;OECN Training Lesson2&quot; parent=&quot;oecn_training_menu&quot; action=&quot;action_oecn_training_classroom_wizard&quot;/&gt; 
    



    注意几点,wizard不需要tree视图,另外,需要在视图动作下加上<field name="target">new</field>。
    这样wizard就出现了,然后可以根据业务逻辑添加自己想要的功能。。

    貌似没有其他的了。。wizard只会挡门外汉,进来了发现没那么难。。



  • [quote author=mrshelly link=topic=16611.msg28995#msg28995 date=1411031355]
    整些没用的. 把最重要的教程搞丢了.
    [/quote]


    嘿嘿。。