Odoo 中文社区

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

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

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

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

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

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

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

    Odoo 新手求助
    2
    5
    4020
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • P
      pen2g 最后由 编辑

      在老肖的请假单上增加对天数的控制,当用户输入大于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
      • Joshua
        Joshua 管理员 最后由 编辑

        校长云:
        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
          pen2g 最后由 编辑

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

           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
            pen2g 最后由 编辑

            此问题在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
            • First post
              Last post