Browse Source

[PORT] Parameter of message "to_read" replaced to "needaction" in mail_move_message_models.py

[PORT] Updated mail_move_message.js for 9.0 compatible
pull/36/head
x620 9 years ago
parent
commit
45baf8b7f5
  1. 2
      mail_move_message/__openerp__.py
  2. 2
      mail_move_message/mail_move_message_models.py
  3. 110
      mail_move_message/static/src/js/mail_move_message.js

2
mail_move_message/__openerp__.py

@ -7,7 +7,7 @@
'website' : 'https://twitter.com/yelizariev',
'price': 9.00,
'currency': 'EUR',
'depends' : ['mail', 'web_polymorphic_field'],
'depends' : ['mail_base', 'web_polymorphic_field'],
'images': ['images/inbox.png'],
'data':[
'mail_move_message_views.xml',

2
mail_move_message/mail_move_message_models.py

@ -74,7 +74,7 @@ class wizard(models.TransientModel):
message_email_from = fields.Char()
message_name_from = fields.Char()
# FIXME message_to_read should be True even if current message or any his childs are unread
message_to_read = fields.Boolean(related='message_id.to_read')
message_to_read = fields.Boolean(related='message_id.needaction')
uid = fields.Integer()
move_followers = fields.Boolean(
'Move Followers',

110
mail_move_message/static/src/js/mail_move_message.js

@ -1,19 +1,29 @@
openerp.mail_move_message = function (session) {
var _t = session.web._t,
_lt = session.web._lt;
odoo.define('mail_move_message.relocate', function (require) {
"use strict";
var mail = session.mail;
var base_obj = require('mail_base.base');
var Model = require('web.Model');
var core = require('web.core');
mail.ThreadMessage.include({
bind_events: function(){
this._super.apply(this, arguments);
this.$('.oe_move').on('click', this.on_move_message)
var QWeb = core.qweb;
var _t = core._t;
var ChatAction = core.action_registry.get('mail.chat.instant_messaging');
ChatAction.include({
start: function() {
var result = this._super.apply(this, arguments);
this.$buttons = $(QWeb.render("mail.chat.ControlButtons", {}));
this.$buttons.find('button').css({display:"inline-block"});
this.$buttons.on('click', '.oe_move', this.on_move_message);
return $.when(result).done(function() {});
},
on_move_message: function(event){
var self = this;
var context = {
'default_message_id': this.id
}
var id = $(event.target).data('oe-id');
var context = {'default_message_id': id};
var action = {
name: _t('Relocate Message'),
type: 'ir.actions.act_window',
@ -22,37 +32,45 @@ openerp.mail_move_message = function (session) {
view_type: 'form',
views: [[false, 'form']],
target: 'new',
context: context,
context: context
};
self.do_action(action, {
'on_close': function(){
self.check_for_rerender();
// TODO: this method is not exist in 9.0. Replace to compatible method
// self.check_for_rerender();
}
});
}
})
});
mail.MessageCommon.include({
init: function (parent, datasets, options) {
this._super(parent, datasets, options);
this.is_moved = datasets.is_moved || false;
base_obj.MailTools.include({
make_message: function(data){
var msg = this._super(data);
msg.is_moved = data.is_moved || false;
return msg;
}
})
});
session.web.form.WidgetButton.include({
on_click: function() {
var widgets = require('web.form_widgets');
widgets.WidgetButton.include({
on_click: function(){
if(this.node.attrs.special == 'quick_create'){
var self = this;
var related_field = this.field_manager.fields[this.node.attrs['field']];
var context_built = $.Deferred();
if(this.node.attrs.use_for_mail_move_message) {
var model = new session.web.Model(this.view.dataset.model);
var model = new Model(this.view.dataset.model);
var partner_id = self.field_manager.fields['partner_id'].get_value();
var message_name_from = self.field_manager.fields['message_name_from'].get_value();
var message_email_from = self.field_manager.fields['message_email_from'].get_value();
context_built = model.call('create_partner', [self.view.dataset.context.default_message_id,
related_field.field.relation, partner_id, message_name_from, message_email_from]);
context_built = model.call('create_partner', [
self.view.dataset.context.default_message_id,
related_field.field.relation,
partner_id,
message_name_from,
message_email_from
]);
}
else {
context_built.resolve(this.build_context());
@ -61,31 +79,31 @@ openerp.mail_move_message = function (session) {
if(self.node.attrs.use_for_mail_move_message) {
self.field_manager.fields['partner_id'].set_value(context['partner_id']);
}
var pop = new session.web.form.FormOpenPopup(this);
pop.show_element(
related_field.field.relation,
false,
context,
{
title: _t("Create new record"),
}
);
pop.on('closed', self, function () {
self.force_disabled = false;
self.check_disable();
});
pop.on('create_completed', self, function(id) {
related_field.set_value(id);
if(self.field_manager.fields['filter_by_partner']) {
self.field_manager.fields['filter_by_partner'].set_value(true);
}
});
// TODO: this method is not exist in 9.0. Create similar method for 9.0
// var pop = new session.web.form.FormOpenPopup(this);
// pop.show_element(
// related_field.field.relation,
// false,
// context,
// {
// title: _t("Create new record"),
// }
// );
// pop.on('closed', self, function () {
// self.force_disabled = false;
// self.check_disable();
// });
// pop.on('create_completed', self, function(id) {
// related_field.set_value(id);
// if(self.field_manager.fields['filter_by_partner']) {
// self.field_manager.fields['filter_by_partner'].set_value(true);
// }
// });
});
}
else {
this._super.apply(this, arguments);
}
},
}
});
}
});
Loading…
Cancel
Save