Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

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

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

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

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

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

    [分享]openerp-server.conf 中配置 dbfilter 参数无效的解决办法

    Odoo 安装指南
    6
    14
    16265
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mrshelly
      mrshelly last edited by

      以前就发现过这个问题, 今天重新在群里同大家讨论了一下.

      有时候可能我们希望用户不从登陆界面的账套选择处进入各个账套(因为如果未曾登陆过OE时, 默认会登陆第一个账套), 这时也容易造成错误. 所以, 一般的做法就是使用 openerp-server.conf 中的 dbfilter 参数进行限定.
      而大部分做法就是

      dbfilter = ^%d$          # 即取 OE WEB访问时取地址栏上 域名的第末子域. 

      即  [检测到链接无效,已移除] 访问时, 会自动设置为 dbfilter = db001

      在 openerp-server.conf 中 限制 db_list = False, dbfilter = ^%d$ 后. 发现并不生效

      从抓包 与 跟踪源码的结果 是
      web 获取当前账套列表 /web/db_list 时, 还是取得了所有的账套列表.
      从 /web/controller/main.py 的 db_list 跟踪得到 openerp.tools.config['dbfilter'] 并没有取到 openerp-server.conf 中的配置项值.而是使用了  /openerp/tools/config.py 文件中

      <br />&nbsp; &nbsp; &nbsp; &nbsp; group.add_option(&quot;--db-filter&quot;, dest=&quot;dbfilter&quot;, default=&#039;.*&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  help=&quot;Filter listed database&quot;, metavar=&quot;REGEXP&quot;)<br />
      



      中的 default='.' 值

      这个 default='.
      ' 将配置文件中的设置又盖掉了.
      开发群中 上海-baggio(317016042) 给出问题所在. 在 /openerp/tools/config.py 文件中, 在 openerp-server.conf 中的生效项. 必须使用 my_default 参数.

      所以, 将上述行代码改成

      <br />&nbsp; &nbsp; &nbsp; &nbsp; group.add_option(&quot;--db-filter&quot;, dest=&quot;dbfilter&quot;, my_default=&#039;.*&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  help=&quot;Filter listed database&quot;, metavar=&quot;REGEXP&quot;)<br />
      



      即可以 让 openerp-server.conf 文件中的 dbfilter 项生效.
      其他的配置 文件项,同样的操作方式..

      感谢 上海-baggio(317016042)  的分享..

      1 Reply Last reply Reply Quote 0
      • C
        ccdos last edited by

        恭喜,这是又抓到了一个 bug  ?

        1 Reply Last reply Reply Quote 0
        • mrshelly
          mrshelly last edited by

          如果用到 dbfilter 那么.... 这豆是一个BUG...

          如果没有用到. 那么 就忽略....

          1 Reply Last reply Reply Quote 0
          • C
            ccdos last edited by

            南京-ccdos(1431494)  15:59:22
            ^%d$  是个正则吗 ?

            我怎么搜不到 %d  的含义呢


            墨尔本-肉山(810333201)  15:59:46
            就是正常的 %d 吧
            重庆-mrshelly(49812643)  15:59:47
            @南京-ccdos  /addons/web/controller/main.py

            db_list method
            %d 非 python 的 %d
            不是 %digit  而是 %domain
            对应还有 %h
            代表  %host

            1 Reply Last reply Reply Quote 0
            • C
              ccdos last edited by

              测试了一下 , OK

              谢谢各位分享

              1 Reply Last reply Reply Quote 0
              • R
                rufeng1199 last edited by

                你那个还是针对配了二级子域名的情况,http://ip:port/web?db=openerp  针对这种情况无效的


                我的做法是 针对这种情况,只能在 init.d 里自启动脚本里 添加  启动命令 附加  [size=13px][font=Verdana]--db-filter='oe8'[/font][/size]

                [font=verdana, arial, helvetica, sans-serif][size=2]这种情况在 openerp8.0下测试通过,客户可以直接访问对外的 pubulic  website 了[/size][/font]


                1 Reply Last reply Reply Quote 0
                • mrshelly
                  mrshelly last edited by

                  db_filter 本意就是使用二级域名来做数据库的自动选择.
                  如果在 init.d 中指定 db-filter 的话,  那一个 OE 实例就只能使用一个账套了.

                  使用二级域名. 可以实现一个OE实例多个账套. 而使用者感觉不到有其他账套存在....

                  1 Reply Last reply Reply Quote 0
                  • R
                    rufeng1199 last edited by

                    谢谢总监大人,我明白了

                    1 Reply Last reply Reply Quote 0
                    • R
                      rufeng1199 last edited by

                      oe8  website特性  要想给公众 public 访问,必须配好单数据库模式,看来只能从oe8代码角度破除这个限制了。

                      1 Reply Last reply Reply Quote 0
                      • mrshelly
                        mrshelly last edited by

                        推荐修改 db_list 或者(db_filter v8.0) 接口,实现顶域与帐套的匹配.

                        [检测到链接无效,已移除]

                        1 Reply Last reply Reply Quote 0
                        • O
                          ooJerry last edited by

                          def db_filter(dbs, httprequest=None):
                              httprequest = httprequest or request.httprequest
                              h = httprequest.environ.get('HTTP_HOST', '').split(':')[0]
                              d, _, r = h.partition('.')
                              if d == "www" and r:
                                  d = r.partition('.')[0]
                              r = openerp.tools.config['dbfilter'].replace('%h', h).replace('%d', d)
                              dbs = [i for i in dbs if re.match(r, i)]
                              return dbs

                          8.0 rc 改成上面这样了,看不懂

                          1 Reply Last reply Reply Quote 0
                          • H
                            hzren last edited by

                            mark一下

                            1 Reply Last reply Reply Quote 0
                            • A
                              aornor last edited by

                              已更新 ODOO8的修改方法 ,参考http://shine-it.net/index.php?topic=16199.msg27338#msg27338

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post