Solved problem with serializable on res.users
bzr revid: nicolas.vanhoren@openerp.com-20121204155817-bvxcp8hzy6ks66n4
This commit is contained in:
parent
7d52b3dbbf
commit
17b0be4505
|
@ -128,7 +128,7 @@ class ImportController(openerp.addons.web.http.Controller):
|
|||
def poll(self, req, last=None, users_watch=None):
|
||||
if not openerp.tools.config.options["gevent"]:
|
||||
raise Exception("Not usable in a server not running gevent")
|
||||
res = req.session.model('res.users').im_connect(context=req.context)
|
||||
req.session.model('res.users').im_connect(context=req.context)
|
||||
num = 0
|
||||
while True:
|
||||
res = req.session.model('im.message').get_messages(last, users_watch, req.context)
|
||||
|
@ -144,7 +144,7 @@ class im_message(osv.osv):
|
|||
_columns = {
|
||||
'message': fields.char(string="Message", size=200, required=True),
|
||||
'from': fields.many2one("res.users", "From", required= True, ondelete='cascade'),
|
||||
'to': fields.many2one("res.users", "From", required=True, select=True, ondelete='cascade'),
|
||||
'to': fields.many2one("res.users", "To", required=True, select=True, ondelete='cascade'),
|
||||
'date': fields.datetime("Date", required=True),
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ class res_user(osv.osv):
|
|||
cr.commit()
|
||||
if current_status != new_one:
|
||||
cr.execute("notify im_channel, %s", [json.dumps({'type': 'status', 'user': uid})])
|
||||
cr.commit()
|
||||
cr.commit()
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
|
|
|
@ -343,9 +343,20 @@ openerp.web_im = function(instance) {
|
|||
}
|
||||
var mes = this.$("input").val();
|
||||
this.$("input").val("");
|
||||
this._add_bubble(this.me, mes, instance.web.datetime_to_str(new Date()));
|
||||
var model = new instance.web.Model("im.message");
|
||||
model.call("post", [mes, this.user.get('id')], {context: new instance.web.CompoundContext()});
|
||||
var send_it = _.bind(function() {
|
||||
var model = new instance.web.Model("im.message");
|
||||
return model.call("post", [mes, this.user.get('id')],
|
||||
{context: new instance.web.CompoundContext()});
|
||||
}, this);
|
||||
var tries = 0;
|
||||
send_it().then(_.bind(function() {
|
||||
this._add_bubble(this.me, mes, instance.web.datetime_to_str(new Date()));
|
||||
}, this), function(error, e) {
|
||||
e.preventDefault();
|
||||
tries += 1;
|
||||
if (tries < 3)
|
||||
return send_it();
|
||||
});
|
||||
},
|
||||
_add_bubble: function(user, item, date) {
|
||||
var items = [item];
|
||||
|
|
Loading…
Reference in New Issue