[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="domain">['|', ('type','=','lead'), ('type','=',False)]</field>
<field name="view_id" ref="crm_case_tree_view_leads"/> <field name="view_id" ref="crm_case_tree_view_leads"/>
<field name="search_view_id" ref="crm.view_crm_case_leads_filter"/> <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"> <field name="help" type="html">
<p class="oe_view_nocontent_create"> <p class="oe_view_nocontent_create">
Click to create an unqualified lead. 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 read: set notification as (un)read
:param bool create_missing: create notifications for missing entries :param bool create_missing: create notifications for missing entries
(i.e. when acting on displayed messages not notified) (i.e. when acting on displayed messages not notified)
:return number of message mark as read
""" """
notification_obj = self.pool.get('mail.notification') 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] 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 # all message have notifications: already set them as (un)read
if len(notif_ids) == len(msg_ids) or not create_missing: 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 # 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)] 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)) to_create_msg_ids = list(set(msg_ids) - set(notified_msg_ids))
for msg_id in to_create_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) 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): def set_message_starred(self, cr, uid, msg_ids, starred, create_missing=True, context=None):
""" Set messages as (un)starred. Technically, the notifications related """ Set messages as (un)starred. Technically, the notifications related

View File

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

View File

@ -1056,9 +1056,7 @@ openerp.mail = function (session) {
msg.renderElement(); msg.renderElement();
msg.start(); msg.start();
} }
if( self.options.root_thread.__parentedParent.__parentedParent.do_reload_menu_emails ) { self.options.root_thread.MailWidget.do_reload_menu_emails();
self.options.root_thread.__parentedParent.__parentedParent.do_reload_menu_emails();
}
}); });
}); });
@ -1198,6 +1196,7 @@ openerp.mail = function (session) {
init: function (parent, datasets, options) { init: function (parent, datasets, options) {
var self = this; var self = this;
this._super(parent, options); this._super(parent, options);
this.MailWidget = parent.__proto__ == mail.Widget.prototype ? parent : false;
this.domain = options.domain || []; this.domain = options.domain || [];
this.context = _.extend(options.context || {}); this.context = _.extend(options.context || {});
@ -1431,11 +1430,16 @@ openerp.mail = function (session) {
message_fetch_set_read: function (message_list) { message_fetch_set_read: function (message_list) {
if (! this.context.mail_read_set_read) return; 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'); msg_ids = _.pluck(message_list, 'id');
return this.ds_message.call('set_message_read', [ return self.ds_message.call('set_message_read', [msg_ids, true, false, self.context])
msg_ids, true, false, this.context]); .then(function (nb_read) {
}, this)); if (nb_read) {
self.options.root_thread.MailWidget.do_reload_menu_emails();
}
});
});
}, },
/** /**
@ -1700,6 +1704,15 @@ openerp.mail = function (session) {
this.bind_events(); 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. *Create the root thread and display this object in the DOM.
* Call the no_message method then c all the message_fetch method * Call the no_message method then c all the message_fetch method
@ -1749,6 +1762,7 @@ openerp.mail = function (session) {
init: function (parent, node) { init: function (parent, node) {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.ParentViewManager = parent;
this.node = _.clone(node); this.node = _.clone(node);
this.node.params = _.extend({ this.node.params = _.extend({
'display_indented_thread': -1, 'display_indented_thread': -1,
@ -1768,7 +1782,7 @@ openerp.mail = function (session) {
this.domain = this.node.params && this.node.params.domain || []; 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; this.node.params.show_link = false;
} }
}, },
@ -1839,6 +1853,7 @@ openerp.mail = function (session) {
*/ */
init: function (parent, action) { init: function (parent, action) {
this._super(parent, action); this._super(parent, action);
this.ActionManager = parent;
this.action = _.clone(action); this.action = _.clone(action);
this.domain = this.action.params.domain || this.action.domain || []; 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 * Load the mail.message search view
* @param {Object} defaults ?? * @param {Object} defaults ??

View File

@ -16,6 +16,11 @@
</field> </field>
</record> </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"> <record model="ir.ui.view" id="sale_view_inherit123">
<field name="name">sale.order.inherit</field> <field name="name">sale.order.inherit</field>
<field name="model">sale.order</field> <field name="model">sale.order</field>