Browse Source

Merge pull request #34 from yelizariev/9.0-mail_reply

9.0 mail reply
pull/37/head
Ivan Yelizariev 9 years ago
parent
commit
92da322630
  1. 8
      mail_base/static/src/js/base.js
  2. 16
      mail_reply/README.rst
  3. 1
      mail_reply/__init__.py
  4. 28
      mail_reply/__openerp__.py
  5. 7
      mail_reply/doc/changelog.rst
  6. 9
      mail_reply/doc/index.rst
  7. BIN
      mail_reply/static/description/icon.png
  8. BIN
      mail_reply/static/description/inbox.png
  9. 29
      mail_reply/static/description/index.html
  10. 46
      mail_reply/static/src/js/mail_reply.js
  11. 10
      mail_reply/static/src/xml/reply_button.xml
  12. 12
      mail_reply/templates.xml

8
mail_base/static/src/js/base.js

@ -786,6 +786,7 @@ chat_manager.post_message = function (data, options) {
subtype_id: data.subtype_id
});
if (options.model && options.res_id){
var model = new Model(options.model);
return model.call('message_post', [options.res_id], msg).then(function (msg_id) {
return MessageModel.call('message_format', [msg_id]).then(function (msgs) {
@ -794,6 +795,13 @@ chat_manager.post_message = function (data, options) {
chat_manager.mail_tools.add_message(msgs[0]);
});
});
} else {
options.model = 'mail.compose.message';
var compose_model = new Model(options.model);
return compose_model.call('create', [msg, {default_parent_id: options.parent_id}]).then(function(id){
return compose_model.call('send_mail_action', [id, {}]);
});
}
}
};
chat_manager.get_message = function (id) {

16
mail_reply/README.rst

@ -0,0 +1,16 @@
==========================
Always show reply button
==========================
The module allows to reply to any message. Out-of-box odoo shows reply button for messages attached to some record.
Further information
===================
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_reply/
Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 9.0 d3dd4161ad0598ebaa659fbd083457c77aa9448d

1
mail_reply/__init__.py

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

28
mail_reply/__openerp__.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
{
"name": """Always show reply button""",
"summary": """Got a message out of a Record? Now you can reply to it too!""",
"category": "Discuss",
"images": [],
"version": "1.0.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
"price": 40.00,
"currency": "EUR",
"depends": [
"mail_base",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
'templates.xml'
],
"qweb": [
"static/src/xml/reply_button.xml",
],
"demo": [],
"installable": True,
"auto_install": False,
}

7
mail_reply/doc/changelog.rst

@ -0,0 +1,7 @@
Changelog
=========
`1.0.0`
-------
- Init version

9
mail_reply/doc/index.rst

@ -0,0 +1,9 @@
===================
Show reply button
===================
Usage
=====
* Open Discuss menu
* All messages have reply button

BIN
mail_reply/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 2.1 KiB

BIN
mail_reply/static/description/inbox.png

After

Width: 761  |  Height: 400  |  Size: 67 KiB

29
mail_reply/static/description/index.html

@ -0,0 +1,29 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Always show reply button</h2>
<h3 class="oe_slogan">Got a message out of a Record? Now you can reply to it too!</h3>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="inbox.png"/>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:it@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:it@it-projects.info">it@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
</ul>
</div>
</div>
</section>

46
mail_reply/static/src/js/mail_reply.js

@ -0,0 +1,46 @@
odoo.define('mail_reply.reply', function (require) {
"use strict";
var core = require('web.core');
var base_obj = require('mail_base.base');
var ChatAction = core.action_registry.get('mail.chat.instant_messaging');
ChatAction.include({
select_message: function(message_id) {
this._super.apply(this, arguments);
var message = base_obj.chat_manager.get_message(message_id);
var subject = '';
if (message.record_name){
subject = "Re: " + message.record_name;
} else if (message.subject){
subject = "Re: " + message.subject;
}
this.extended_composer.set_subject(subject);
},
on_post_message: function(message){
var self = this;
var options = this.selected_message ? {} : {channel_id: this.channel.id};
if (this.selected_message) {
message.subtype = 'mail.mt_comment';
message.subtype_id = false;
message.message_type = 'comment';
message.content_subtype = 'html';
options.model = this.selected_message.model;
options.res_id = this.selected_message.res_id;
options.parent_id = this.selected_message.id;
}
base_obj.chat_manager
.post_message(message, options)
.then(function() {
if (self.selected_message) {
self.render_snackbar('mail.chat.MessageSentSnackbar', {record_name: self.selected_message.record_name}, 5000);
self.unselect_message();
} else {
self.thread.scroll_to();
}
});
}
});
});

10
mail_reply/static/src/xml/reply_button.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<t t-extend="mail.ChatThread.Message">
<t t-jquery='i[class="fa fa-reply o_thread_message_reply"]' t-operation="replace">
<i t-if="message.model != 'mail.channel' &amp;&amp; options.display_reply_icon"
class="fa fa-reply o_thread_message_reply"
t-att-data-message-id="message.id" title="Reply"/>
</t>
</t>
</template>

12
mail_reply/templates.xml

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<openerp>
<data>
<template id="mail_reply_assets_backend"
name="mail_reply_assets_backend"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script src="/mail_reply/static/src/js/mail_reply.js" type="text/javascript"></script>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save