跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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. 请教,新API,onchange中判断输入有误,如何提示红色对话框?或弹出错误窗口?

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

已定时 已固定 已锁定 已移动 Odoo 开发与实施交流
6 帖子 2 发布者 2.4k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • L 离线
    L 离线
    lipeng260
    写于 最后由 编辑
    #1

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

    @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
    
    1 条回复 最后回复
    0
    • mrshellyM 离线
      mrshellyM 离线
      mrshelly
      写于 最后由 编辑
      #2
      <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 />
      
      1 条回复 最后回复
      0
      • L 离线
        L 离线
        lipeng260
        写于 最后由 编辑
        #3

        [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]

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

        1 条回复 最后回复
        0
        • mrshellyM 离线
          mrshellyM 离线
          mrshelly
          写于 最后由 编辑
          #4

          其他原因...

          1 条回复 最后回复
          0
          • L 离线
            L 离线
            lipeng260
            写于 最后由 编辑
            #5

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

            1 条回复 最后回复
            0

            • 登录

            • 没有帐号? 注册

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