[FIX] crm_partner_assign: on forward, set section_id if user_id has default section id

bzr revid: dle@openerp.com-20140107105324-xaa21r8fnl0ncg66
This commit is contained in:
Denis Ledoux 2014-01-07 11:53:24 +01:00
parent 720526249b
commit e5e397b01b
2 changed files with 24 additions and 2 deletions

View File

@ -139,6 +139,8 @@ class crm_lead_forward_to_partner(osv.TransientModel):
values = {'partner_assigned_id': partner_id, 'user_id': partner_leads['partner'].user_id.id}
if stage_id:
values['stage_id'] = stage_id
if partner_leads['partner'].user_id:
values['section_id'] = partner_leads['partner'].user_id.default_section_id.id
lead_obj.write(cr, uid, lead_ids, values)
self.pool.get('crm.lead').message_subscribe(cr, uid, lead_ids, [partner_id], context=context)
return True

View File

@ -88,6 +88,7 @@ function declare($, _, openerp) {
this.users_cache = {};
this.last = null;
this.unload_event_handler = _.bind(this.unload, this);
this.on("new_conversation", this, this.load_history);
},
start_polling: function() {
var self = this;
@ -252,11 +253,20 @@ function declare($, _, openerp) {
}
return def.then(function() {return conv});
},
load_history: function(conv){
var self = this;
im_common.connection.model("im.message").call("search", [[["session_id", "=", conv.session_id]], 0, 10]).then(function(message_ids){
im_common.connection.model("im.message").call("read", [message_ids]).then(function(messages){
messages.reverse();
self.received_messages(messages);
});
});
},
received_messages: function(messages) {
var self = this;
var defs = [];
var received = false;
_.each(messages, function(message) {
function post_message(message) {
if (! message.technical) {
defs.push(self.activate_session(message.session_id[0]).then(function(conv) {
received = self.my_id !== message.from_id[0];
@ -267,6 +277,15 @@ function declare($, _, openerp) {
message.json = json;
defs.push($.when(im_common.technical_messages_handlers[json.type](self, message)));
}
}
_.each(messages, function(message){
if (defs.length > 0){
debugger;
defs[defs.length - 1].then(post_message(message));
}
else{
post_message(message);
}
});
return $.when.apply($, defs).then(function(){
if (! self.get("window_focus") && received) {
@ -400,7 +419,7 @@ function declare($, _, openerp) {
} else {
this.set("pending", this.get("pending") + 1);
}
this.c_manager.ensure_users([message.from_id[0]]).then(_.bind(function(users) {
return this.c_manager.ensure_users([message.from_id[0]]).then(_.bind(function(users) {
var user = users[0];
if (! _.contains(this.get("users"), user) && ! _.contains(this.others, user)) {
this.others.push(user);
@ -447,6 +466,7 @@ function declare($, _, openerp) {
return new Array(size - str.length + 1).join('0') + str;
};
date = "" + zpad(date.getHours(), 2) + ":" + zpad(date.getMinutes(), 2);
debugger;
var to_show = _.map(items, im_common.escape_keep_url);
this.last_bubble = $(openerp.qweb.render("im_common.conversation_bubble", {"items": to_show, "user": user, "time": date}));
$(this.$(".oe_im_chatview_content").children()[0]).append(this.last_bubble);