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

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

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

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

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



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

    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}}
    

    <br /><br />view.xml修改的代码:<br />

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

    <br />


  • 管理员

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

    <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 />
    


  • 感谢版主,解决了。不过答案少了个符号(在月字后)。正确的代码如下:<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;  }<br />&nbsp; &nbsp; &nbsp;  return {&#039;value&#039;:{&#039;tians&#039;:30},&#039;warning&#039;: warning}
    


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