跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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. Web client 的 addons 样例模块...

Web client 的 addons 样例模块...

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

    不多说, 一个最小化的 web client addons 样例. 于附件

    init.py

    <br />import test<br />
    



    openerp.py

    <br /><br />{<br />&nbsp; &nbsp; &quot;name&quot; : &quot;OpenERP Web client Addons Sample&quot;,<br />&nbsp; &nbsp; &quot;version&quot; : &quot;1.0&quot;,<br />&nbsp; &nbsp; &quot;depends&quot; : &#91;],<br />&nbsp; &nbsp; &quot;author&quot; : &quot;mrshelly&quot;,<br />&nbsp; &nbsp; &quot;description&quot;: &quot;&quot;&quot;OpenERP Web client. Addons Sample moudle<br />&nbsp; &nbsp; &quot;&quot;&quot;,<br />&nbsp; &nbsp; &#039;website&#039;: &#039;http://www.mrshelly.com/&#039;,<br />&nbsp; &nbsp; &#039;active&#039;: True,<br />}<br /><br />
    



    logo.gif
    请下载任意 图片文件


    test.py

    <br />import base64,os,re<br /><br />import cherrypy<br />from openerp.controllers import SecuredController<br />from openerp.utils import rpc, common, TinyDict, TinyForm, expr_eval<br />import openobject<br />from openobject.tools import expose, redirect, validate, error_handler, exception_handler<br /><br />class TestForm(SecuredController):<br /><br />&nbsp; &nbsp; _cp_path = &quot;/openerp/test&quot;<br /><br />&nbsp; &nbsp; @expose(content_type=&#039;image/png&#039;)<br />&nbsp; &nbsp; def show_test_image(self, **kw):<br />&nbsp; &nbsp; &nbsp; &nbsp; return open(openobject.paths.addons(&#039;test&#039;,&#039;logo.gif&#039;),&#039;rb&#039;).read()<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; # /openerp/test/show_test_image<br />
    



    模块下载[attachurl=1]

    解压到 web client addons 路径, 并重启 web client 服务即可.


    上个效果图:
    [attachimg=2]

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

      赞!感谢shelly分享

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

        访问
        <br / [检测到链接无效,已移除] br />

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

          return的一般来说是html页面?

          这个不错,完全可以做出个类似速达的功能导航界面来。

          GoodERP -- Odoo China fork

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

            理论上

            @expose(content_type='text/html; charset=utf-8')

            修改 content_type 再输出 页面内容就可以了.

            1 条回复 最后回复
            0

            • 登录

            • 没有帐号? 注册

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