Thibault Delavallée (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-openchatter-dom-chm into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-openchatter-dom-chm/+merge/132164
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-openchatter-dom-chm/+merge/132164
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-openchatter-dom-chm.
=== modified file 'mail/mail_message_view.xml'
--- mail/mail_message_view.xml	2012-10-29 09:08:47 +0000
+++ mail/mail_message_view.xml	2012-10-30 16:29:24 +0000
@@ -59,21 +59,24 @@
                     <field name="type"/>
                     <field name="author_id"/>
                     <field name="partner_ids"/>
+                    <filter string="Read"
+                            name="message_read" help="Show messages to read"
+                            domain="[('to_read', '=', False)]"/>
                     <filter string="Unread"
                             name="message_unread" help="Show messages to read"
                             domain="[('to_read', '=', True)]"/>
                     <filter string="Comments"
                             name="comments" help="Comments"
                             domain="[('type', '=', 'comment')]"/>
-                    <filter string="Has attachments"
-                            name="attachments"
-                            domain="[('attachment_ids', '!=', False)]"/>
                     <filter string="Notifications"
                             name="notifications" help="Notifications"
                             domain="[('type', '=', 'notification')]"/>
                     <filter string="Emails"
                             name="emails" help="Emails"
                             domain="[('type', '=', 'email')]"/>
+                    <filter string="Has attachments"
+                            name="attachments"
+                            domain="[('attachment_ids', '!=', False)]"/>
                 </search>
             </field>
         </record>
@@ -84,7 +87,6 @@
             <field name="view_type">form</field>
             <field name="view_mode">tree,form</field>
             <field name="search_view_id" ref="view_message_search"/>
-            <field name="context">{'search_default_to_read_message':True}</field>
         </record>
         
         <!-- Add menu entry in Settings/Email -->

=== modified file 'mail/mail_thread_view.xml'
--- mail/mail_thread_view.xml	2012-10-29 09:08:47 +0000
+++ mail/mail_thread_view.xml	2012-10-30 16:29:24 +0000
@@ -5,35 +5,35 @@
             <field name="name">Inbox</field>
             <field name="tag">mail.wall</field>
             <field name="params" eval="&quot;{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid]), ('to_read', '=', True)],
-                'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'inbox'} }&quot;"/>
+                'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
         </record>
 
         <record id="action_mail_to_me_feeds" model="ir.actions.client">
             <field name="name">To: me</field>
             <field name="tag">mail.wall</field>
             <field name="params" eval="&quot;{'domain': [('partner_ids.user_ids', 'in', [uid]), ('to_read', '=', True), ('author_id.user_ids', 'in', [uid])],
-                'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'inbox'} }&quot;"/>
+                'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
         </record>
 
         <record id="action_mail_star_feeds" model="ir.actions.client">
             <field name="name">Favorites</field>
             <field name="tag">mail.wall</field>
             <field name="params" eval="&quot;{'domain': [('favorite_user_ids.user_ids', 'in', [uid])],
-                'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'stared'} }&quot;"/>
+                'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
         </record>
 
         <record id="action_mail_archives_feeds" model="ir.actions.client">
             <field name="name">Archives</field>
             <field name="tag">mail.wall</field>
             <field name="params" eval="&quot;{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid]), ('to_read', '=', False)],
-                'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'archives'} }&quot;"/>
+                'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
         </record>
 
         <record id="action_mail_sent_feeds" model="ir.actions.client">
             <field name="name">Sent</field>
             <field name="tag">mail.wall</field>
             <field name="params" eval="&quot;{'domain': [('author_id.user_ids', 'in', [uid])],
-                'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'send'} }&quot;"/>
+                'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
         </record>
 
         <!-- MENU -->

=== modified file 'mail/static/src/css/mail.css'
--- mail/static/src/css/mail.css	2012-10-29 14:45:03 +0000
+++ mail/static/src/css/mail.css	2012-10-30 16:29:24 +0000
@@ -1,3 +1,30 @@
+/* ------------ TOPBAR MAIL BUTTON --------------- */
+
+/* FIXME this css is not very pretty because it uses a 
+ * 'button' element wich comes with a lot of inappropriate 
+ * styling. Entypo is also a headache to center properly
+ * */
+
+.openerp .oe_topbar_item.oe_topbar_compose_full_email{ 
+    padding: 0px;
+    width: 32px;
+    height: 32px;
+}
+.openerp .oe_topbar_item.oe_topbar_compose_full_email button{
+    position: relative;
+    top: -3px;  /* centering entypo ... urgh */
+    box-sizing: border-box;
+    border: none;
+    box-shadow: none;
+    color: white;
+    background: none;
+    text-shadow: 0px 1px 2px black;
+    width: 32px;
+    height: 32px;
+    padding: 0px;
+    margin: 0px
+    border-radius: 0px;
+}
 
 /* ------------ MAIL WIDGET --------------- */
 .openerp .oe_mail, .openerp .oe_mail *{
@@ -80,18 +107,21 @@
 .openerp .oe_mail .oe_msg.oe_msg_indented .oe_msg_content{
     padding-top:2px;
 }
+
 /* b) Votes (likes) */
+
 .openerp .oe_mail .oe_mail_vote_count{
     display: inline;
     position: relative;
-    background: #7C7BAD;
-    color: white;
+    background: white;
+    box-shadow: 0px 0px 0px 1px rgba(124, 123, 173, 0.36) inset;
+    color: #7c7bad;
     text-shadow: none;
     border-radius: 3px;
     margin: 0px;
     padding-left: 3px;
-    padding-right: 18px;
-    margin-right: 3px;
+    padding-right: 15px;
+    margin-right: 5px;
 }
 .openerp .oe_mail .oe_mail_vote_count .oe_e{
     position: absolute;
@@ -155,7 +185,7 @@
 }
 .openerp .oe_mail .oe_msg .oe_msg_content textarea{
     width: 100%;
-    height: 32px;
+    height: 64px;
     margin: 0px;
     padding: 0px;
     resize: vertical;
@@ -269,6 +299,7 @@
 
 .openerp .oe_mail .oe_msg_content.oe_msg_more_message{
     text-align: right;
+    cursor: pointer;
 }
 .openerp .oe_mail .oe_msg_content.oe_msg_more_message .oe_separator{
     height: 0;
@@ -280,7 +311,7 @@
 }
 .openerp .oe_mail .oe_msg_more_message .oe_msg_fetch_more {
     background: white;
-    margin-right: 280px;
+    margin-right: 210px;
     padding-left: 8px;
     padding-right: 8px;
     text-decoration: none;
@@ -298,6 +329,7 @@
     padding-top: 5px;
     width: 160px;
     float: right;
+    margin-right: 16px;
 }
 
 /*  a) THE FOLLOW BUTTON */
@@ -371,12 +403,13 @@
 
 .openerp .oe_record_thread{
     display: block;
-    margin-right: 180px;
+    margin-left: 16px;
+    margin-right: 212px;
 }
 
 /* ----------- INBOX INTEGRATION ----------- */
 
 .openerp .oe_mail_wall .oe_mail{
     margin: 16px;
-    width: 720px;
+    width: 600px;
 }

=== modified file 'mail/static/src/js/mail.js'
--- mail/static/src/js/mail.js	2012-10-29 14:28:56 +0000
+++ mail/static/src/js/mail.js	2012-10-30 16:29:24 +0000
@@ -145,15 +145,16 @@
             this.show_compact_message = false;
 
             // data of this compose message
-            this.attachment_ids = [];
             this.id = datasets.id;
             this.model = datasets.model;
             this.res_model = datasets.res_model;
             this.is_private = datasets.is_private || false;
             this.partner_ids = datasets.partner_ids || [];
-            this.avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid);
             this.thread_level = datasets.thread_level;
+
+            this.attachment_ids = [];
             this.parent_thread= parent.messages!= undefined ? parent : false;
+            this.avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid);
 
             this.ds_attachment = new session.web.DataSetSearch(this, 'ir.attachment');
             this.show_delete_attachment = true;
@@ -358,8 +359,13 @@
                         this.parent_thread.context
                     ]).then(function (record) {
                         var thread = self.parent_thread;
+
+                        if (self.options.display_indented_thread < self.thread_level && thread.parent_message) {
+                            thread = thread.parent_message.parent_thread;
+                        }
                         // create object and attach to the thread object
                         thread.message_fetch(false, false, [record], function (arg, data) {
+                            data[0].no_sorted = true;
                             var message = thread.create_message_object( data[0] );
                             // insert the message on dom
                             thread.insert_message( message, self.$el );
@@ -439,7 +445,7 @@
             this.type = 'expandable',
             this.max_limit = this.id < 0 || false,
             this.flag_used = false,
-            this.parent_thread= parent.messages!= undefined ? parent : this.options._parents[0];
+            this.parent_thread= parent.messages!= undefined ? parent : this.options.root_thread;
         },
 
         
@@ -459,7 +465,7 @@
          * Bind events in the widget. Each event is slightly described
          * in the function. */
         bind_events: function () {
-            this.$el.on('click', 'a.oe_msg_fetch_more', this.on_expandable);
+            this.$el.on('click', '.oe_msg_more_message', this.on_expandable);
         },
 
         animated_destroy: function (fadeTime) {
@@ -529,12 +535,14 @@
          *              display before having a "show more" link; note that the text
          *              will not be truncated if it does not have 110% of the parameter
          *          @param {Boolean} [show_record_name]
-         *...  @param {int} [show_reply_button] number thread level to display the reply button
-         *...  @param {int} [show_read_unread_button] number thread level to display the read/unread button
+         *...  @param {boolean} [show_reply_button] display the reply button
+         *...  @param {boolean} [show_read_unread_button] display the read/unread button
          */
         init: function (parent, datasets, context) {
             this._super(parent);
 
+            // record options
+            this.options = datasets.options || {};
             // record domain and context
             this.domain = datasets.domain || [];
             this.context = _.extend({
@@ -542,36 +550,16 @@
                 default_res_id: 0,
                 default_parent_id: false }, context || {});
 
-            // record options
-            this.options = datasets.options;
-
             // data of this message
-            this.id = datasets.id ||  -1,
-            this.model = datasets.model ||  false,
-            this.parent_id = datasets.parent_id ||  false,
-            this.res_id = datasets.res_id ||  false,
-            this.type = datasets.type ||  false,
-            this.is_author = datasets.is_author ||  false,
-            this.is_private = datasets.is_private ||  false,
-            this.subject = datasets.subject ||  false,
-            this.name = datasets.name ||  false,
-            this.record_name = datasets.record_name ||  false,
-            this.body = datasets.body ||  false,
-            this.vote_nb = datasets.vote_nb || 0,
-            this.has_voted = datasets.has_voted ||  false,
-            this.is_favorite = datasets.is_favorite ||  false,
-            this.thread_level = datasets.thread_level ||  0,
-            this.to_read = datasets.to_read || false,
-            this.author_id = datasets.author_id ||  [],
-            this.attachment_ids = datasets.attachment_ids ||  [],
+            for (var k in datasets) {
+                this[k] = datasets[k];
+            }
             this._date = datasets.date;
 
-
-            this.show_reply_button = this.options.show_compose_message && this.options.show_reply_button > this.thread_level;
-            this.show_read_unread_button = this.options.show_read_unread_button > this.thread_level;
+            this.show_record_name = this.record_name && !this.thread_level && this.model!='res.partner';
 
             // record options and data
-            this.parent_thread= parent.messages!= undefined ? parent : this.options._parents[0];
+            this.parent_thread= parent.messages!= undefined ? parent : this.options.root_thread;
             this.thread = false;
 
             if ( this.id > 0 ) {
@@ -672,10 +660,10 @@
             this.$('.oe_msg_body:first').expander({
                 slicePoint: this.options.truncate_limit,
                 expandText: 'read more',
-                userCollapseText: '[^]',
+                userCollapseText: '&atilde',
                 detailClass: 'oe_msg_tail',
                 moreClass: 'oe_mail_expand',
-                lessClass: 'oe_mail_reduce',
+                lessClass: 'oe_mail_reduce oe_e',
                 });
         },
 
@@ -731,6 +719,15 @@
             return false;
         },
 
+        /* Check if the message must be destroy and detroy it
+        * @param {callback} apply function
+        */
+        check_for_destroy: function () {
+            var domain = mail.ChatterUtils.expand_domain( this.options.root_thread.domain ).concat([["id", "=", this.id]]);
+            this.parent_thread.ds_message.call('message_read', [undefined, domain, [], 0, this.context, this.parent_thread.id])
+                .then( _.bind(function (record) { if (!record || !record.length) this.animated_destroy(150); }, this) );
+        },
+
         /*The selected thread and all childs (messages/thread) became read
         * @param {object} mouse envent
         */
@@ -738,16 +735,14 @@
             event.stopPropagation();
             var self=this;
 
-            if ( (this.to_read && this.options.typeof_thread == 'inbox') ||
-                (!this.to_read && this.options.typeof_thread == 'archives')) {
-                this.animated_destroy(150);
-            }
-
             // if this message is read, all childs message display is read
-            this.ds_notification.call('set_message_read', [ [this.id].concat( this.get_child_ids() ) , this.to_read, this.context]).pipe(function () {
-                self.$el.removeClass(self.to_read ? 'oe_msg_unread':'oe_msg_read').addClass(self.to_read ? 'oe_msg_read':'oe_msg_unread');
-                self.to_read = !self.to_read;
-            });
+            this.ds_notification.call('set_message_read', [ [this.id].concat( this.get_child_ids() ) , this.to_read, this.context])
+                .then(function () {
+                    self.$el.removeClass(self.to_read ? 'oe_msg_unread':'oe_msg_read').addClass(self.to_read ? 'oe_msg_read':'oe_msg_unread');
+                    self.to_read = !self.to_read;
+                    // check if the message must be display
+                    self.check_for_destroy();
+                });
             return false;
         },
 
@@ -764,8 +759,8 @@
             // goto the wall thread for launch browse
             if (!options._go_thread_wall) {
                 options._go_thread_wall = true;
-                for (var i in this.options._parents[0].messages) {
-                    var res=this.options._parents[0].messages[i].browse_message(options);
+                for (var i in this.options.root_thread.messages) {
+                    var res=this.options.root_thread.messages[i].browse_message(options);
                     if (res) return res;
                 }
             }
@@ -800,12 +795,13 @@
         */
         on_vote: function (event) {
             event.stopPropagation();
-            var self=this;
-            return this.ds_message.call('vote_toggle', [[self.id]]).pipe(function (vote) {
-                self.has_voted = vote;
-                self.vote_nb += self.has_voted ? 1 : -1;
-                self.display_vote();
-            });
+            return this.ds_message.call('vote_toggle', [[this.id]])
+                .then(
+                    _.bind(function (vote) {
+                        this.has_voted = vote;
+                        this.vote_nb += this.has_voted ? 1 : -1;
+                        this.display_vote();
+                    }, this));
             return false;
         },
 
@@ -813,10 +809,9 @@
          * Display the render of this message's vote
         */
         display_vote: function () {
-            var self = this;
-            var vote_element = session.web.qweb.render('mail.thread.message.vote', {'widget': self});
-            self.$(".oe_msg_vote:first").remove();
-            self.$(".oe_mail_vote_count:first").replaceWith(vote_element);
+            var vote_element = session.web.qweb.render('mail.thread.message.vote', {'widget': this});
+            this.$(".oe_msg_footer:first .oe_mail_vote_count").remove();
+            this.$(".oe_msg_footer:first .oe_msg_vote").replaceWith(vote_element);
         },
 
         /**
@@ -826,17 +821,17 @@
             event.stopPropagation();
             var self=this;
             var button = self.$('.oe_star:first');
-            return this.ds_message.call('favorite_toggle', [[self.id]]).pipe(function (star) {
-                self.is_favorite=star;
-                if (self.is_favorite) {
-                    button.addClass('oe_starred');
-                } else {
-                    button.removeClass('oe_starred');
-                    if ( self.options.typeof_thread == 'stared' ) {
-                        self.animated_destroy(150);
+            this.ds_message.call('favorite_toggle', [[self.id]])
+                .then(function (star) {
+                    self.is_favorite=star;
+                    if (self.is_favorite) {
+                        button.addClass('oe_starred');
+                    } else {
+                        button.removeClass('oe_starred');
+                        // check if the message must be display
+                        self.check_for_destroy();
                     }
-                }
-            });
+                });
             return false;
         },
 
@@ -880,9 +875,6 @@
          *      @param {Object} [thread]
          *          @param {int} [display_indented_thread] number thread level to indented threads.
          *              other are on flat mode
-         *          @param {Select} [typeof_thread] inbox/archives/stared/sent
-         *              type of thread and option for user application like animate
-         *              destroy for read/unread
          *          @param {Array} [parents] liked with the parents thread
          *              use with browse, fetch... [O]= top parent
          */
@@ -895,7 +887,8 @@
                 default_parent_id: false }, options.context || {});
 
             this.options = options.options;
-            this.options._parents = (options.options._parents != undefined ? options.options._parents : []).concat( [this] );
+            this.options.root_thread = (options.options.root_thread != undefined ? options.options.root_thread : this);
+            this.options.show_compose_message = this.options.show_compose_message && (this.options.display_indented_thread >= this.thread_level || !this.thread_level);
 
             // record options and data
             this.parent_message= parent.thread!= undefined ? parent : false ;
@@ -909,8 +902,7 @@
             this.thread_level =  (datasets.thread_level+1) || 0,
             this.partner_ids =  _.filter(datasets.partner_ids, function (partner) { return partner[0]!=datasets.author_id[0]; } ) 
             this.messages = [];
-            this.show_compose_message = this.options.show_compose_message && (this.options.show_reply_button > this.thread_level || !this.thread_level);
-
+            
             // object compose message
             this.compose_message = false;
 
@@ -947,21 +939,20 @@
         /* When the expandable object is visible on screen (with scrolling)
          * then the on_expandable function is launch
         */
-        on_scroll: function (event) {
-            if (event)event.stopPropagation();
-            this.$('.oe_msg_expandable:last');
-
-            var message = this.messages[this.messages.length-1];
-            if (message && message.type=="expandable" && message.max_limit) {
-                var pos = message.$el.position();
+        on_scroll: function () {
+            var expandables = 
+            _.each( _.filter(this.messages, function (val) {return val.id == -1 && !val.loading;}), function (val) {
+                var pos = val.$el.position();
                 if (pos.top) {
                     /* bottom of the screen */
                     var bottom = $(window).scrollTop()+$(window).height()+200;
                     if (bottom > pos.top) {
-                        message.on_expandable();
+                        val.on_expandable();
+                        // load only one time
+                        val.loading = true;
                     }
                 }
-            }
+            });
         },
 
         /**
@@ -980,6 +971,7 @@
             var p=$(this).parent(); 
             p.find('.oe_more_hidden, .oe_hidden').show(); 
             p.find('.oe_more').hide(); 
+            return false;
         },
 
         /**
@@ -989,6 +981,7 @@
             var p=$(this).parent(); 
             p.find('.oe_more_hidden, .oe_hidden').hide(); 
             p.find('.oe_more').show(); 
+            return false;
         },
 
         /* get all child message/thread id linked.
@@ -1032,17 +1025,17 @@
             // goto the wall thread for launch browse
             if (!options._go_thread_wall) {
                 options._go_thread_wall = true;
-                return this.options._parents[0].browse_thread(options);
+                return this.options.root_thread.browse_thread(options);
             }
 
-            if (this.id==options.id) {
+            if (this.id == options.id) {
                 return this;
             }
 
             if (options.id) {
                 for (var i in this.messages) {
                     if (this.messages[i].thread) {
-                        var res=this.messages[i].thread.browse_thread({'id':options.id, '_go_thread_wall':true});
+                        var res = this.messages[i].thread.browse_thread({'id':options.id, '_go_thread_wall':true});
                         if (res) return res;
                     }
                 }
@@ -1066,8 +1059,8 @@
          * @return message object
          */
         browse_message: function (options) {
-            if (this.options._parents[0].messages[0])
-                return this.options._parents[0].messages[0].browse_message(options);
+            if (this.options.root_thread.messages[0])
+                return this.options.root_thread.messages[0].browse_message(options);
         },
 
         /**
@@ -1078,6 +1071,7 @@
         on_compose_message: function () {
             this.instantiate_compose_message();
             this.compose_message.on_compose_expandable();
+            return false;
         },
 
         /**
@@ -1100,18 +1094,20 @@
          * @param {Array} ids read (if the are some ids, the method don't use the domain)
          */
         message_fetch: function (replace_domain, replace_context, ids, callback) {
-            var self = this;
-
-            // domain and context: options + additional
-            fetch_domain = replace_domain ? replace_domain : this.domain;
-            fetch_context = replace_context ? replace_context : this.context;
-            var message_loaded_ids = this.id ? [this.id].concat( self.get_child_ids() ) : self.get_child_ids();
-
-            // CHM note : option for sending in flat mode by server
-            var thread_level = this.options.display_indented_thread > this.thread_level ? this.options.display_indented_thread - this.thread_level : 0;
-
-            return this.ds_message.call('message_read', [ids, fetch_domain, message_loaded_ids, thread_level, fetch_context, this.context.default_parent_id || undefined])
-                .then(callback ? _.bind(callback, this, arguments) : this.proxy('switch_new_message'));
+            return this.ds_message.call('message_read', [
+                    // ids force to read
+                    ids, 
+                    // domain + additional
+                    (replace_domain ? replace_domain : this.domain), 
+                    // ids allready loaded
+                    (this.id ? [this.id].concat( this.get_child_ids() ) : this.get_child_ids()), 
+                    // option for sending in flat mode by server
+                    (this.options.display_indented_thread > this.thread_level ? this.options.display_indented_thread - this.thread_level : 0), 
+                    // context + additional
+                    (replace_context ? replace_context : this.context), 
+                    // parent_id
+                    this.context.default_parent_id || undefined
+                ]).done(callback ? _.bind(callback, this, arguments) : this.proxy('switch_new_message'));
         },
 
         /**
@@ -1163,7 +1159,7 @@
         insert_message: function (message, dom_insert_after) {
             var self=this;
 
-            if (this.show_compose_message && this.options.show_compact_message) {
+            if (this.options.show_compact_message) {
                 this.instantiate_compose_message();
                 this.compose_message.do_show_compact();
             }
@@ -1181,6 +1177,9 @@
             var message_older = false;
             if (message.id > 0) {
                 for (var i in self.messages) {
+                    if (self.messages[i].no_sorted) {
+                        continue;
+                    } 
                     if (self.messages[i].id > message.id) {
                         if (!message_newer || message_newer.id > self.messages[i].id) {
                             message_newer = self.messages[i];
@@ -1261,6 +1260,7 @@
         on_message_detroy: function (message) {
 
             this.messages = _.filter(this.messages, function (val) { return !val.isDestroyed(); });
+            return false;
 
         },
 
@@ -1367,15 +1367,13 @@
          * @param {Object} [context] context of the thread. It should
          *   contain at least default_model, default_res_id. Please refer to
          *   the compose_message widget for more information about it.
-         * ... @param {Select} [typeof_thread=(mail|stared|archives|send|other)]
-         *       options for destroy message when the user click on a button
          * @param {Object} [options]
          *...  @param {Number} [truncate_limit=250] number of character to
          *      display before having a "show more" link; note that the text
          *      will not be truncated if it does not have 110% of the parameter
          *...  @param {Boolean} [show_record_name] display the name and link for do action
-         *...  @param {int} [show_reply_button] number thread level to display the reply button
-         *...  @param {int} [show_read_unread_button] number thread level to display the read/unread button
+         *...  @param {boolean} [show_reply_button] display the reply button
+         *...  @param {boolean} [show_read_unread_button] display the read/unread button
          *...  @param {int} [display_indented_thread] number thread level to indented threads.
          *      other are on flat mode
          *...  @param {Boolean} [show_compose_message] allow to display the composer
@@ -1392,10 +1390,9 @@
             this.search_results = {'domain': [], 'context': {}, 'groupby': {}};
 
             this.options = _.extend({
-                'typeof_thread' : 'inbox',
                 'display_indented_thread' : -1,
-                'show_reply_button' : -1,
-                'show_read_unread_button' : -1,
+                'show_reply_button' : false,
+                'show_read_unread_button' : false,
                 'truncate_limit' : 250,
                 'show_record_name' : false,
                 'show_compose_message' : false,
@@ -1407,12 +1404,6 @@
             if (this.display_indented_thread === false) {
                 this.display_indented_thread = -1;
             }
-            if (this.show_reply_button === false) {
-                this.show_reply_button = -1;
-            }
-            if (this.show_read_unread_button === false) {
-                this.show_read_unread_button = -1;
-            }
             
         },
 
@@ -1451,11 +1442,10 @@
         },
 
         bind_events: function () {
-            if (this.context['typeof_thread']!='other') {
-                $(document).scroll( this.thread.on_scroll );
-                $(window).resize( this.thread.on_scroll );
-                window.setTimeout( this.thread.on_scroll, 500 );
-            }
+            $(document).scroll( _.bind(this.thread.on_scroll, this.thread) );
+            $(window).resize( _.bind(this.thread.on_scroll, this.thread) );
+            this.$el.resize( _.bind(this.thread.on_scroll, this.thread) );
+            window.setTimeout( _.bind(this.thread.on_scroll, this.thread), 500 );
         }
     });
 
@@ -1474,12 +1464,6 @@
     mail.RecordThread = session.web.form.AbstractField.extend({
         template: 'mail.record_thread',
 
-        init: function () {
-            this._super.apply(this, arguments);
-            this.options.domain = this.options.domain || [];
-            this.options.context = {'default_model': 'mail.thread', 'default_res_id': false};
-        },
-
         start: function () {
             this._super.apply(this, arguments);
             // NB: check the actual_mode property on view to know if the view is in create mode anymore
@@ -1490,38 +1474,31 @@
         _check_visibility: function () {
             this.$el.toggle(this.view.get("actual_mode") !== "create");
         },
+
         render_value: function () {
             var self = this;
             if (! this.view.datarecord.id || session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) {
                 this.$('oe_mail_thread').hide();
                 return;
             }
-            // update context
-            _.extend(this.options.context, {
-                default_res_id: this.view.datarecord.id,
-                default_model: this.view.model,
-                default_is_private: false });
-            // update domain
-            var domain = this.options.domain.concat([['model', '=', this.view.model], ['res_id', '=', this.view.datarecord.id]]);
-
-            var show_compose_message = this.view.is_action_enabled('edit') ||
-                (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value());
-
-            var message_ids = this.getParent().fields.message_ids && this.getParent().fields.message_ids.get_value();
 
             if (this.root) {
+                $('<span class="oe_mail-placeholder"/>').insertAfter(this.root.$el);
                 this.root.destroy();
             }
             // create and render Thread widget
             this.root = new mail.Widget(this, {
-                'domain' : domain,
-                'context' : this.options.context,
-                'typeof_thread': this.options.context['typeof_thread'] || 'other',
+                'domain' : (this.options.domain || []).concat([['model', '=', this.view.model], ['res_id', '=', this.view.datarecord.id]]),
+                'context' : {
+                    'default_res_id': this.view.datarecord.id || false,
+                    'default_model': this.view.model || 'mail.thread',
+                    'default_is_private': false 
+                },
                 'display_indented_thread': -1,
-                'show_reply_button': 0,
-                'show_read_unread_button': -1,
-                'show_compose_message': show_compose_message,
-                'message_ids': message_ids,
+                'show_reply_button': false,
+                'show_read_unread_button': false,
+                'show_compose_message': this.view.is_action_enabled('edit') || (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()),
+                'message_ids': this.getParent().fields.message_ids ? this.getParent().fields.message_ids.get_value() : undefined,
                 'show_compact_message': true,
                 'no_message': this.node.attrs.help
                 }
@@ -1557,17 +1534,23 @@
             this.options = options || {};
             this.options.domain = options.domain || [];
             this.options.context = options.context || {};
-            this.search_results = {'domain': [], 'context': {}, 'groupby': {}}
-            this.ds_msg = new session.web.DataSetSearch(this, 'mail.message');
+
+            this.options.defaults = {};
+            for (var key in options.context) {
+                if(key.match(/^search_default_/)) {
+                    this.options.defaults[key.replace(/^search_default_/, '')] = options.context[key];
+                }
+            }
         },
 
         start: function () {
-            this._super.apply(this, arguments);
-            var searchview_ready = this.load_searchview({}, false);
-            var thread_displayed = this.message_render();
-            this.options.domain = this.options.domain.concat(this.search_results['domain']);
+            this._super.apply(this);
+            this.load_searchview(this.options.defaults, false);
             this.bind_events();
-            return $.when(searchview_ready, thread_displayed);
+
+            if(!this.searchview.has_defaults) {
+                this.message_render();
+            }
         },
 
         /**
@@ -1577,10 +1560,14 @@
          */
         load_searchview: function (defaults, hidden) {
             var self = this;
-            this.searchview = new session.web.SearchView(this, this.ds_msg, false, defaults || {}, hidden || false);
-            return this.searchview.appendTo(this.$('.oe_view_manager_view_search')).then(function () {
-                self.searchview.on('search_data', self, self.do_searchview_search);
-            });
+            var ds_msg = new session.web.DataSetSearch(self, 'mail.message');
+            self.searchview = new session.web.SearchView(self, ds_msg, false, defaults || {}, hidden || false);
+            self.searchview.appendTo(self.$('.oe_view_manager_view_search'))
+                .then(function () { self.searchview.on('search_data', self, self.do_searchview_search); });
+            if (this.searchview.has_defaults) {
+                this.searchview.ready.then(this.searchview.do_search);
+            }
+            return self.searchview
         },
 
         /**
@@ -1597,10 +1584,11 @@
                 contexts: contexts || [],
                 group_by_seq: groupbys || []
             }).then(function (results) {
-                self.search_results['context'] = results.context;
-                self.search_results['domain'] = results.domain;
-                self.root.destroy();
-                return self.message_render();
+                if(self.root) {
+                    $('<span class="oe_mail-placeholder"/>').insertAfter(self.root.$el);
+                    self.root.destroy();
+                }
+                return self.message_render(results);
             });
         },
 
@@ -1608,16 +1596,15 @@
         /**
          *Create the root thread widget and display this object in the DOM
           */
-        message_render: function (search) {
-            var domain = this.options.domain.concat(this.search_results['domain']);
-            var context = _.extend(this.options.context, search&&search.search_results['context'] ? search.search_results['context'] : {});
+        message_render: function ( search ) {
+            var domain = this.options.domain.concat(search && search['domain'] ? search['domain'] : []);
+            var context = _.extend(this.options.context, search && search['context'] ? search['context'] : {});
             this.root = new mail.Widget(this, {
                 'domain' : domain,
                 'context' : context,
-                'typeof_thread': context['typeof_thread'] || 'other',
                 'display_indented_thread': 1,
-                'show_reply_button': 10,
-                'show_read_unread_button': 11,
+                'show_reply_button': true,
+                'show_read_unread_button': true,
                 'show_compose_message': true,
                 'show_compact_message': false,
                 }
@@ -1642,23 +1629,11 @@
      * Add a link on the top user bar for write a full mail
      */
     session.web.ComposeMessageTopButton = session.web.Widget.extend({
-        template:'mail.compose_message.button_top_bar',
-
-        init: function (parent, options) {
-            this._super.apply(this, options);
-            this.options = this.options || {};
-            this.options.domain = this.options.domain || [];
-            this.options.context = {
-                'default_model': false,
-                'default_res_id': 0,
-                'default_content_subtype': 'html',
-            };
-        },
-
-        start: function (parent, params) {
-            var self = this;
-            this.$el.on('click', 'button', self.on_compose_message );
-            this._super(parent, params);
+        template:'mail.ComposeMessageTopButton',
+
+        start: function () {
+            this.$el.on('click', 'button', this.on_compose_message );
+            this._super();
         },
 
         on_compose_message: function (event) {
@@ -1668,26 +1643,23 @@
                 res_model: 'mail.compose.message',
                 view_mode: 'form',
                 view_type: 'form',
-                action_from: 'mail.ThreadComposeMessage',
                 views: [[false, 'form']],
                 target: 'new',
-                context: _.extend(this.options.context, {
-                    'default_model': this.context.default_model,
-                    'default_res_id': this.context.default_res_id,
-                    'default_content_subtype': 'html',
-                }),
+                context: { 'default_content_subtype': 'html' },
             };
             session.client.action_manager.do_action(action);
         },
-
     });
 
-    session.web.UserMenu = session.web.UserMenu.extend({
-        start: function (parent, params) {
-            var render = new session.web.ComposeMessageTopButton();
-            render.insertAfter(this.$el);
-            this._super(parent, params);
-        }
+    session.web.UserMenu.include({
+        do_update: function(){
+            var self = this;
+            this._super.apply(this, arguments);
+            this.update_promise.then(function() {
+                var mail_button = new session.web.ComposeMessageTopButton();
+                mail_button.appendTo(session.webclient.$el.find('.oe_systray'));
+            });
+        },
     });
 
 };

=== modified file 'mail/static/src/xml/mail.xml'
--- mail/static/src/xml/mail.xml	2012-10-29 14:45:03 +0000
+++ mail/static/src/xml/mail.xml	2012-10-30 16:29:24 +0000
@@ -140,9 +140,7 @@
                 <td colspan="2">
                     <h2 class="oe_view_title">
                         <span class="oe_view_title_text">
-                            News Feed
-                            <t t-if="widget.options.res_model"> / </t>
-                            <t t-if="widget.options.res_model" t-esc="widget.options.res_model"/>
+                            Email box
                         </span>
                     </h2>
                 </td>
@@ -197,9 +195,9 @@
 
             <div class="oe_msg_center">
                 <div class='oe_msg_icons'>
-                    <span class='oe_read' t-if="widget.show_read_unread_button"><a title="Read" class="oe_e">X</a></span>
-                    <span class='oe_unread' t-if="widget.show_read_unread_button"><a title="Set back to unread" class="oe_e">v</a></span>
-                    <span class='oe_reply' t-if="widget.show_reply_button"><a title="Reply" class="oe_e">(</a></span>
+                    <span class='oe_read' t-if="widget.options.show_read_unread_button"><a title="Read" class="oe_e">X</a></span>
+                    <span class='oe_unread' t-if="widget.options.show_read_unread_button"><a title="Set back to unread" class="oe_e">v</a></span>
+                    <span class='oe_reply' t-if="widget.options.show_reply_button"><a title="Reply" class="oe_e">(</a></span>
                     <span t-attf-class="oe_star #{widget.is_favorite?'oe_starred':''}"><a title="Add To Favorites" class="oe_e">7</a></span>
                 </div>
                 <!-- message itself -->
@@ -208,7 +206,7 @@
                         <t t-raw="widget.subject"/>
                     </h1>
                     <div class="oe_msg_body">
-                        <t t-if="widget.options.show_record_name and widget.record_name and (!widget.subject) and !widget.options.thread_level and !widget.options.display_on_thread[0] and widget.model!='res.partner'">
+                        <t t-if="widget.show_record_name">
                             <a class="oe_mail_action_model" t-attf-href="#model=#{widget.model}&amp;id=#{widget.res_id}"><t t-raw="widget.record_name"/></a>
                         </t>
                         <t t-raw="widget.body"/>
@@ -234,11 +232,12 @@
 
     <!-- expandable message layout -->
     <t t-name="mail.thread.expandable">
-        <div t-attf-class="oe_msg oe_msg_#{widget.type} #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''} oe_msg_unread">
+        <div t-attf-class="oe_msg oe_msg_#{widget.type} #{widget.max_limit ? 'oe_max_limit' : ''} #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''} oe_msg_unread">
             <div class="oe_msg_content oe_msg_more_message">
                 <div class='oe_separator'></div>
+                <a t-if="widget.nb_messages &lt;= 0" class="oe_msg_fetch_more">show more message</a>
                 <a t-if="widget.nb_messages === 1" class="oe_msg_fetch_more">show one more message</a>
-                <a t-if="widget.nb_messages !== 1" class="oe_msg_fetch_more">show <t t-raw="widget.nb_messages" /> more messages</a>
+                <a t-if="widget.nb_messages &gt; 1" class="oe_msg_fetch_more">show <t t-raw="widget.nb_messages" /> more messages</a>
             </div>
         </div>
     </t>
@@ -247,9 +246,9 @@
         mail.compose_message.button_top_bar
         render of the button on the user bar for open wizard compose message
         -->
-    <t t-name="mail.compose_message.button_top_bar">
-        <div class="oe_topbar_compose_full_email">
-            <!-- <button class="oe_button oe_highlight">Write an email</button> -->
+    <t t-name="mail.ComposeMessageTopButton">
+        <div title='Compose new Message' class="oe_topbar_item oe_topbar_compose_full_email">
+            <button class="oe_e">%</button>
         </div>
     </t>
 
@@ -257,12 +256,11 @@
         Template used to display Like/Unlike in a mail.message
     -->
     <span t-name="mail.thread.message.vote">
-        
         <span class="oe_mail_vote_count" t-if='widget.vote_nb > 0'>
             <t t-raw='widget.vote_nb' />
             <span class='oe_e'>8</span>
         </span>
-        <a href='#' t-attf-class="oe_msg_vote">
+        <a href='#' class="oe_msg_vote">
             <t t-if="!widget.has_voted">like</t>
             <t t-if="widget.has_voted">unlike</t>
         </a>

=== modified file 'note/note_view.xml'
--- note/note_view.xml	2012-10-26 17:17:01 +0000
+++ note/note_view.xml	2012-10-30 16:29:24 +0000
@@ -120,7 +120,7 @@
                 <field name="memo" widget="html" class="oe_memo" editor_height="450px" />
                 <div class="oe_chatter">
                     <field name="message_follower_ids" widget="mail_followers"/>
-                    <field class="oe_chatter" name="message_ids" widget="mail_thread"/>
+                    <field name="message_ids" widget="mail_thread"/>
                 </div>
             </form>
         </field>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to