跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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. 如何控制的数字控件按要求输入?

如何控制的数字控件按要求输入?

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

    在老肖的请假单上增加对天数的控制,当用户输入大于31天,我想提示错误并回写成30天,但提示后代码无法继续执行,即天数还是31天请教解决办法
    py上增加的代码:

    def onchange_qingjia_tians(self, cr, uid, ids, tians):<br />&nbsp; &nbsp; &nbsp;  if tians&gt;30:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise osv.except_osv(_(&#039;Error !&#039;), _(&quot;不允许请假超过一个月.&quot;))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return {&#039;value&#039;:{&#039;tians&#039;:30}}
    



    view.xml修改的代码:

    &lt;field name=&quot;tians&quot; select=&quot;1&quot; on_change=&quot;onchange_qingjia_tians(tians)&quot;/&gt;
    

    1 条回复 最后回复
    0
    • JoshuaJ 离线
      JoshuaJ 离线
      Joshua 管理员
      写于 最后由 编辑
      #2

      校长云:
      raise osv.except_osv
      就是异常了,下面就不会执行return了

      试试

      <br /> warning = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;title&#039;: _(&#039;Error!&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;message&#039;: _(&#039;不允许请假超过一个月.&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />return {&#039;value&#039;:{&#039;tians&#039;:30},&#039;warning&#039;: warning}<br />
      

      【上海先安科技】(joshua AT openerp.cn),欢迎关注公众号:openerp_cn

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

        感谢版主,解决了。不过答案少了个符号(在月字后)。正确的代码如下:

         warning = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;title&#039;: _(&#039;Error!&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;message&#039;: _(&#039;不允许请假超过一个月.&#039;)<br />&nbsp; &nbsp; &nbsp;  }<br />&nbsp; &nbsp; &nbsp;  return {&#039;value&#039;:{&#039;tians&#039;:30},&#039;warning&#039;: warning}
        
        1 条回复 最后回复
        0
        • P 离线
          P 离线
          pen2g
          写于 最后由 编辑
          #4

          此问题在GTK客户端运行正常,在WEB下没反应,网上搜到,有人提交了这个BUG<br / https://bugs.launchpad.net/openobject-client-web/+bug/789121 br />Bug Description
          .This work fin with gtk 6.0.2 , onchange function is not started with web client 6.0.2
          It's important, my prospect use only web client!

          1 条回复 最后回复
          0

          • 登录

          • 没有帐号? 注册

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