跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

  1. 主页
  2. 版块
  3. Odoo 开发与实施交流
  4. 手把手教你在7.0下开发wizard【多亏了总监指导,大家一起感谢他】

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

已定时 已固定 已锁定 已移动 Odoo 开发与实施交流
5 帖子 2 发布者 4.0k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • 阿 离线
    阿 离线
    阿狸
    写于 最后由 编辑
    #1

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


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

    1 条回复 最后回复
    0
    • mrshellyM 离线
      mrshellyM 离线
      mrshelly
      写于 最后由 编辑
      #2

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

      1 条回复 最后回复
      0
      • 阿 离线
        阿 离线
        阿狸
        写于 最后由 编辑
        #3

        首先,先安装前两个模块,即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只会挡门外汉,进来了发现没那么难。。

        1 条回复 最后回复
        0
        • 阿 离线
          阿 离线
          阿狸
          写于 最后由 编辑
          #4

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


          嘿嘿。。

          1 条回复 最后回复
          0

          • 登录

          • 没有帐号? 注册

          • 登录或注册以进行搜索。
          • 第一个帖子
            最后一个帖子
          0
          • 版块
          • 标签
          • 热门
          • 用户
          • 群组