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

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

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

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

请教,新API,onchange中判断输入有误,如何提示红色对话框?或弹出错误窗口?



  • 尝试这样的代码无效,请教。

    @api.onchange(&#039;available_num&#039;) # if these fields are changed, call method<br />&nbsp; &nbsp; def check_change(self):<br />&nbsp; &nbsp; &nbsp; &nbsp; if self.available_num &gt; self.num:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context={}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context[&quot;key&quot;]=&quot;value&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ret = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;type&#039;: &#039;ir.actions.client&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;tag&#039;: &#039;bs.error_message&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;context&#039;: context,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ret
    


  • <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; warning = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;title&#039;: _(&#039;Warning!&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;message&#039;: _(&#039;You must first select a partner!&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return {&#039;warning&#039;: warning}<br />
    


  • [quote author=mrshelly link=topic=17351.msg31220#msg31220 date=1445908853]

    <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; warning = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;title&#039;: _(&#039;Warning!&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;message&#039;: _(&#039;You must first select a partner!&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return {&#039;warning&#039;: warning}<br />
    


    [/quote]

    提示出字段无效的那种如何实现?



  • 其他原因...



  • 我跟踪js代码,找到 instance.web.View类中有this.do_warn(_t("The following fields are invalid:"), warnings.join(''));这个方法,请教在python服务器端如何调用?
    是否应该在js中获取onchange方法,在js中判断后直接返回do_warn?