[IMP] ir_ui_menu: trunk to 7.0 dynamic counters

bzr revid: chm@openerp.com-20130417133205-lx4lh53y6ak29cjc
This commit is contained in:
Christophe Matthieu 2013-04-17 15:32:05 +02:00
parent 51d5126fee
commit 14493f56ce
5 changed files with 46 additions and 30 deletions

View File

@ -9,7 +9,13 @@
<field name="domain">['|', ('type','=','lead'), ('type','=',False)]</field>
<field name="view_id" ref="crm_case_tree_view_leads"/>
<field name="search_view_id" ref="crm.view_crm_case_leads_filter"/>
<field name="context">{'default_type':'lead', 'stage_type':'lead'}</field>
<field name="context">{
'default_type':'lead',
'stage_type':'lead',
'search_default_unassigned':1,
'needaction_menu_ref': 'crm.menu_crm_opportunities',
}
</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create an unqualified lead.

View File

@ -233,6 +233,8 @@ class mail_message(osv.Model):
:param bool read: set notification as (un)read
:param bool create_missing: create notifications for missing entries
(i.e. when acting on displayed messages not notified)
:return number of message mark as read
"""
notification_obj = self.pool.get('mail.notification')
user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0]
@ -243,14 +245,16 @@ class mail_message(osv.Model):
# all message have notifications: already set them as (un)read
if len(notif_ids) == len(msg_ids) or not create_missing:
return notification_obj.write(cr, uid, notif_ids, {'read': read}, context=context)
notification_obj.write(cr, uid, notif_ids, {'read': read}, context=context)
return len(notif_ids)
# some messages do not have notifications: find which one, create notification, update read status
notified_msg_ids = [notification.message_id.id for notification in notification_obj.browse(cr, uid, notif_ids, context=context)]
to_create_msg_ids = list(set(msg_ids) - set(notified_msg_ids))
for msg_id in to_create_msg_ids:
notification_obj.create(cr, uid, {'partner_id': user_pid, 'read': read, 'message_id': msg_id}, context=context)
return notification_obj.write(cr, uid, notif_ids, {'read': read}, context=context)
notification_obj.write(cr, uid, notif_ids, {'read': read}, context=context)
return len(notif_ids)
def set_message_starred(self, cr, uid, msg_ids, starred, create_missing=True, context=None):
""" Set messages as (un)starred. Technically, the notifications related

View File

@ -8,6 +8,7 @@
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
'needaction_menu_ref': ['mail.mail_tomefeeds', 'mail.mail_starfeeds']
}</field>
<field name="params" eval="&quot;{
'domain': [
@ -36,7 +37,8 @@
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
'search_default_message_unread': True
'search_default_message_unread': True,
'needaction_menu_ref': ['mail.mail_starfeeds', 'mail.mail_inboxfeeds']
}</field>
<field name="params" eval="&quot;{
'domain': [
@ -87,7 +89,8 @@
<field name="tag">mail.wall</field>
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid
'default_res_id': uid,
'needaction_menu_ref': ['mail.mail_tomefeeds', 'mail.mail_starfeeds', 'mail.mail_inboxfeeds']
}</field>
<field name="params" eval="&quot;{
'domain': [

View File

@ -1056,9 +1056,7 @@ openerp.mail = function (session) {
msg.renderElement();
msg.start();
}
if( self.options.root_thread.__parentedParent.__parentedParent.do_reload_menu_emails ) {
self.options.root_thread.__parentedParent.__parentedParent.do_reload_menu_emails();
}
self.options.root_thread.MailWidget.do_reload_menu_emails();
});
});
@ -1198,6 +1196,7 @@ openerp.mail = function (session) {
init: function (parent, datasets, options) {
var self = this;
this._super(parent, options);
this.MailWidget = parent.__proto__ == mail.Widget.prototype ? parent : false;
this.domain = options.domain || [];
this.context = _.extend(options.context || {});
@ -1431,11 +1430,16 @@ openerp.mail = function (session) {
message_fetch_set_read: function (message_list) {
if (! this.context.mail_read_set_read) return;
this.render_mutex.exec(_.bind(function() {
var self = this;
this.render_mutex.exec(function() {
msg_ids = _.pluck(message_list, 'id');
return this.ds_message.call('set_message_read', [
msg_ids, true, false, this.context]);
}, this));
return self.ds_message.call('set_message_read', [msg_ids, true, false, self.context])
.then(function (nb_read) {
if (nb_read) {
self.options.root_thread.MailWidget.do_reload_menu_emails();
}
});
});
},
/**
@ -1700,6 +1704,15 @@ openerp.mail = function (session) {
this.bind_events();
},
/**
* crete an object "related_menu"
* contain the menu widget and the the sub menu related of this wall
*/
do_reload_menu_emails: function () {
var ActionManager = this.__parentedParent.ActionManager || this.__parentedParent.__parentedParent.ViewManager.ActionManager;
ActionManager.__parentedParent.menu.do_reload_needaction();
},
/**
*Create the root thread and display this object in the DOM.
* Call the no_message method then c all the message_fetch method
@ -1749,6 +1762,7 @@ openerp.mail = function (session) {
init: function (parent, node) {
this._super.apply(this, arguments);
this.ParentViewManager = parent;
this.node = _.clone(node);
this.node.params = _.extend({
'display_indented_thread': -1,
@ -1768,7 +1782,7 @@ openerp.mail = function (session) {
this.domain = this.node.params && this.node.params.domain || [];
if (!this.__parentedParent.is_action_enabled('edit')) {
if (!this.ParentViewManager.is_action_enabled('edit')) {
this.node.params.show_link = false;
}
},
@ -1839,6 +1853,7 @@ openerp.mail = function (session) {
*/
init: function (parent, action) {
this._super(parent, action);
this.ActionManager = parent;
this.action = _.clone(action);
this.domain = this.action.params.domain || this.action.domain || [];
@ -1871,23 +1886,6 @@ openerp.mail = function (session) {
}
},
/**
* crete an object "related_menu"
* contain the menu widget and the the sub menu related of this wall
*/
do_reload_menu_emails: function () {
var menu = this.__parentedParent.__parentedParent.menu;
// return this.rpc("/web/menu/load", {'menu_id': 100}).done(function(r) {
// _.each(menu.data.data.children, function (val) {
// if (val.id == 100) {
// val.children = _.find(r.data.children, function (r_val) {return r_val.id == 100;}).children;
// }
// });
// var r = menu.data;
// window.setTimeout(function(){menu.do_reload();}, 0);
// });
},
/**
* Load the mail.message search view
* @param {Object} defaults ??

View File

@ -16,6 +16,11 @@
</field>
</record>
<!-- add needaction_menu_ref to reload quotation needaction when opportunity needaction is reloaded -->
<record model="ir.actions.act_window" id="crm.crm_case_category_act_oppor11">
<field name="context">{'stage_type': 'opportunity', 'default_type': 'opportunity', 'default_user_id': uid, 'needaction_menu_ref': 'sale.menu_sale_quotations'}</field>
</record>
<record model="ir.ui.view" id="sale_view_inherit123">
<field name="name">sale.order.inherit</field>
<field name="model">sale.order</field>