请教,@api.multi def write(self, vals): 返回{'warning': warning},无效??
-
在@api.onchange中可以,在这里为什么不行,请教。
@api.multi<br /> def write(self, vals):<br /> parent_id = self.search([('id', '=', vals['parent_id'])])<br /> def check(self, id):<br /> if(self.parent_id):<br /> return check(self.parent_id, id) and id != self.id<br /> else:<br /> return id != self.id<br /> if check(parent_id, self.id):<br /> return super(classify, self).write(vals)<br /> else:<br /> warning = {<br /> 'title': "Warning!",<br /> 'message': "the available num Can't be more than the num",<br /> }<br /> return {'warning': warning}
-
自己研究了下,已解决。。。。
instance.web.list.Editor.include(/** @lends instance.web.ListView# */{<br /> save: function () {<br /> var self = this;<br /> return this.form<br /> .save(this.delegate.prepends_on_create())<br /> .then(function (result) {<br /> var created = result.created && !self.record.id;<br /> if (created) {<br /> self.record.id = result.result;<br /> }<br /> if (!_.isEmpty(result.warning)) {<br /> new instance.web.Dialog(this, {<br /> size: 'medium',<br /> title:result.warning.title,<br /> buttons: [<br /> {text: _t("Ok"), click: function() { this.parents('.modal').modal('hide'); }}<br /> ]<br /> }, QWeb.render("CrashManager.warning", result.warning)).open();<br /> }<br /> return self.cancel();<br /> });<br /> },<br /> })