Odoo 中文社区

    • 注册
    • 登录
    • 搜索
    • 版块
    • 标签
    • 热门
    • 用户
    • 群组

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

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

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

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

    Web client 的 addons 样例模块...

    Odoo 开发与实施交流
    3
    6
    5118
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • mrshelly
      mrshelly 最后由 编辑

      不多说, 一个最小化的 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
        hifly 最后由 编辑

        赞!感谢shelly分享

        1 条回复 最后回复 回复 引用 0
        • mrshelly
          mrshelly 最后由 编辑

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

          1 条回复 最后回复 回复 引用 0
          • wjfonhand
            wjfonhand 最后由 编辑

            return的一般来说是html页面?

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

            GoodERP -- Odoo China fork

            1 条回复 最后回复 回复 引用 0
            • mrshelly
              mrshelly 最后由 编辑

              理论上

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

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

              1 条回复 最后回复 回复 引用 0
              • First post
                Last post