[IMP] mail: launch widget with action (action contain params, context...)
bzr revid: chm@openerp.com-20121105155450-3uyauk63cc2nakkn
This commit is contained in:
@@ -4,60 +4,89 @@
|
||||
<record id="action_mail_inbox_feeds" model="ir.actions.client">
|
||||
<field name="name">Inbox</field>
|
||||
<field name="tag">mail.wall</field>
|
||||
<field name="params" eval=""{
|
||||
<field name="context">{
|
||||
'default_model': 'res.users',
|
||||
'default_res_id': uid
|
||||
}</field>
|
||||
<field name="params">{
|
||||
'domain': [
|
||||
('notification_ids.partner_id.user_ids', 'in', [uid]),
|
||||
('to_read', '=', True),
|
||||
('favorite_user_ids', 'not in', [uid])
|
||||
],
|
||||
'context': {'default_model': 'res.users', 'default_res_id': uid},
|
||||
('notification_ids.partner_id.user_ids', 'in', [uid]),
|
||||
('to_read', '=', True),
|
||||
('favorite_user_ids', 'not in', [uid])
|
||||
],
|
||||
'view_mailbox': True,
|
||||
'view_inbox': True,
|
||||
'read_action': 'read', }""/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
'read_action': 'read'
|
||||
}</field>
|
||||
<field name="help">
|
||||
There are no message in your mailbox for this search.
|
||||
</p>
|
||||
</field>
|
||||
</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="context">{
|
||||
'default_model': 'res.users',
|
||||
'default_res_id': uid,
|
||||
'search_default_message_unread': True
|
||||
}</field>
|
||||
<field name="params" eval=""{
|
||||
'domain': [('partner_ids.user_ids', 'in', [uid])],
|
||||
'context': {'default_model': 'res.users', 'default_res_id': uid, 'search_default_message_unread': True},
|
||||
'view_mailbox': True,
|
||||
'read_action': 'read', }""/>
|
||||
<field name="help">
|
||||
There are no message in your private mailbox for this search.
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_mail_star_feeds" model="ir.actions.client">
|
||||
<field name="name">Todo</field>
|
||||
<field name="tag">mail.wall</field>
|
||||
<field name="context">{
|
||||
'default_model': 'res.users',
|
||||
'default_res_id': uid,
|
||||
'search_default_message_unread': True
|
||||
}</field>
|
||||
<field name="params" eval=""{
|
||||
'domain': [('favorite_user_ids', 'in', [uid])],
|
||||
'context': {'default_model': 'res.users', 'default_res_id': uid, 'search_default_message_unread': True},
|
||||
'view_mailbox': True,
|
||||
'read_action': 'read', }""/>
|
||||
<field name="help">
|
||||
There are no message in your todo mailbox for this search.
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_mail_archives_feeds" model="ir.actions.client">
|
||||
<field name="name">Done</field>
|
||||
<field name="tag">mail.wall</field>
|
||||
<field name="context">{
|
||||
'default_model': 'res.users',
|
||||
'default_res_id': uid,
|
||||
'search_default_message_unread': True
|
||||
}</field>
|
||||
<field name="params" eval=""{
|
||||
'domain': [('notification_ids.partner_id.user_ids', 'in', [uid])],
|
||||
'context': {'default_model': 'res.users', 'default_res_id': uid, 'search_default_message_read': True},
|
||||
'view_mailbox': True,
|
||||
'read_action': 'unread', }""/>
|
||||
<field name="help">
|
||||
There are no message for this search.
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_mail_sent_feeds" model="ir.actions.client">
|
||||
<field name="name">Sent</field>
|
||||
<field name="tag">mail.wall</field>
|
||||
<field name="context">{
|
||||
'default_model': 'res.users',
|
||||
'default_res_id': uid
|
||||
}</field>
|
||||
<field name="params" eval=""{
|
||||
'domain': [('author_id.user_ids', 'in', [uid])],
|
||||
'context': {'default_model': 'res.users', 'default_res_id': uid},
|
||||
'view_mailbox': True, }""/>
|
||||
<field name="help">
|
||||
There are no message for this search.
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- MENU -->
|
||||
|
||||
@@ -1138,8 +1138,8 @@ openerp.mail = function (session) {
|
||||
*/
|
||||
no_message: function () {
|
||||
var no_message = $(session.web.qweb.render('mail.wall_no_message', {}));
|
||||
if (this.options.no_message) {
|
||||
no_message.html(this.options.no_message);
|
||||
if (this.options.help) {
|
||||
no_message.html(this.options.help);
|
||||
}
|
||||
no_message.appendTo(this.$el);
|
||||
},
|
||||
@@ -1387,12 +1387,12 @@ openerp.mail = function (session) {
|
||||
* @param {String} [no_message] Message to display when there are no message
|
||||
*/
|
||||
init: function (parent, action) {
|
||||
var options = action.params || {};
|
||||
this._super(parent);
|
||||
this.domain = options.domain || [];
|
||||
this.context = options.context || {};
|
||||
this.action = _.clone(action);
|
||||
this.domain = this.action.domain || this.action.params.domain || [];
|
||||
this.context = this.action.context || this.action.params.context || {};
|
||||
|
||||
this.options = _.extend({
|
||||
this.action.params = _.extend({
|
||||
'display_indented_thread' : -1,
|
||||
'show_reply_button' : false,
|
||||
'show_read_unread_button' : false,
|
||||
@@ -1402,8 +1402,9 @@ openerp.mail = function (session) {
|
||||
'show_compact_message' : false,
|
||||
'view_inbox': false,
|
||||
'message_ids': undefined,
|
||||
'no_message': false
|
||||
}, options);
|
||||
}, this.action.params);
|
||||
|
||||
this.action.params.help = this.action.help || false;
|
||||
},
|
||||
|
||||
start: function (options) {
|
||||
@@ -1422,21 +1423,23 @@ openerp.mail = function (session) {
|
||||
this.thread = new mail.Thread(this, {}, {
|
||||
'domain' : this.domain,
|
||||
'context' : this.context,
|
||||
'options': this.options,
|
||||
'options': this.action.params,
|
||||
});
|
||||
|
||||
this.thread.appendTo( this.$el );
|
||||
this.thread.no_message();
|
||||
this.thread.message_fetch(null, null, this.options.message_ids);
|
||||
|
||||
if (this.options.show_compose_message) {
|
||||
if (this.action.params.show_compose_message) {
|
||||
this.thread.instantiate_compose_message();
|
||||
if (this.options.show_compact_message) {
|
||||
if (this.action.params.show_compact_message) {
|
||||
this.thread.compose_message.do_show_compact();
|
||||
} else {
|
||||
this.thread.compose_message.do_hide_compact();
|
||||
}
|
||||
}
|
||||
|
||||
this.thread.message_fetch(null, null, this.action.params.message_ids);
|
||||
|
||||
},
|
||||
|
||||
bind_events: function () {
|
||||
@@ -1464,7 +1467,22 @@ openerp.mail = function (session) {
|
||||
|
||||
init: function (parent, action) {
|
||||
this._super(parent);
|
||||
this.action = action;
|
||||
this.action = _.clone(action);
|
||||
|
||||
this.action.params = _.extend(this.action.params, {
|
||||
'display_indented_thread': -1,
|
||||
'show_reply_button': false,
|
||||
'show_read_unread_button': false,
|
||||
'show_compose_message': this.view.is_action_enabled('edit'),
|
||||
'message_ids': this.getParent().fields.message_ids ? this.getParent().fields.message_ids.get_value() : undefined,
|
||||
'show_compact_message': 1,
|
||||
});
|
||||
this.action.context = {
|
||||
'default_res_id': this.view.datarecord.id || false,
|
||||
'default_model': this.view.model || false,
|
||||
};
|
||||
this.action.domain = this.action.domain || this.action.params.domain || [];
|
||||
|
||||
},
|
||||
|
||||
start: function () {
|
||||
@@ -1490,20 +1508,10 @@ openerp.mail = function (session) {
|
||||
this.root.destroy();
|
||||
}
|
||||
// create and render Thread widget
|
||||
this.root = new mail.Widget(this, {
|
||||
this.root = new mail.Widget(this, _.extend(this.action, {
|
||||
'domain' : (this.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 || false,
|
||||
},
|
||||
'display_indented_thread': -1,
|
||||
'show_reply_button': false,
|
||||
'show_read_unread_button': false,
|
||||
'show_compose_message': this.view.is_action_enabled('edit'),
|
||||
'message_ids': this.getParent().fields.message_ids ? this.getParent().fields.message_ids.get_value() : undefined,
|
||||
'show_compact_message': 1,
|
||||
'no_message': this.action.help,
|
||||
});
|
||||
|
||||
}));
|
||||
|
||||
return this.root.replace(this.$('.oe_mail-placeholder'));
|
||||
},
|
||||
@@ -1534,17 +1542,25 @@ openerp.mail = function (session) {
|
||||
init: function (parent, action) {
|
||||
this._super(parent);
|
||||
|
||||
this.action = action;
|
||||
var options = action.params || {};
|
||||
this.options = options || {};
|
||||
this.domain = options.domain || [];
|
||||
this.context = options.context || {};
|
||||
this.action = _.clone(action);
|
||||
this.domain = this.action.domain || this.action.params.domain || [];
|
||||
this.context = this.action.context || this.action.params.context || {};
|
||||
|
||||
this.defaults = {};
|
||||
for (var key in options.context) {
|
||||
for (var key in this.context) {
|
||||
if (key.match(/^search_default_/)) {
|
||||
this.defaults[key.replace(/^search_default_/, '')] = options.context[key];
|
||||
this.defaults[key.replace(/^search_default_/, '')] = this.context[key];
|
||||
}
|
||||
}
|
||||
|
||||
this.action.params = _.extend(this.action.params, {
|
||||
'display_indented_thread': 1,
|
||||
'show_reply_button': true,
|
||||
'show_read_unread_button': true,
|
||||
'show_compose_message': true,
|
||||
'show_compact_message': this.context.view_mailbox ? false : 1,
|
||||
'view_inbox': !!this.context.view_inbox,
|
||||
});
|
||||
},
|
||||
|
||||
start: function () {
|
||||
@@ -1601,18 +1617,11 @@ openerp.mail = function (session) {
|
||||
message_render: function (search) {
|
||||
var domain = this.domain.concat(search && search['domain'] ? search['domain'] : []);
|
||||
var context = _.extend(this.context, search && search['context'] ? search['context'] : {});
|
||||
this.root = new mail.Widget(this, _.extend(this.options, {
|
||||
|
||||
this.root = new mail.Widget(this, _.extend(this.action, {
|
||||
'domain' : domain,
|
||||
'context' : context,
|
||||
'display_indented_thread': 1,
|
||||
'show_reply_button': true,
|
||||
'show_read_unread_button': true,
|
||||
'show_compose_message': true,
|
||||
'show_compact_message': this.context.view_mailbox ? false : 1,
|
||||
'view_inbox': !!this.context.view_inbox,
|
||||
'no_message': this.action.help
|
||||
})
|
||||
);
|
||||
}));
|
||||
return this.root.replace(this.$('.oe_mail-placeholder'));
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user