Browse Source

Merge pull request #36 from x620/mail-addons-9.0-res_partner_mails_count

Mail addons 9.0 mail_base and mail_archives
pull/6/head
Ivan Yelizariev 9 years ago
parent
commit
e0853bebe9
  1. 15
      mail_archives/README.rst
  2. 3
      mail_archives/__init__.py
  3. 26
      mail_archives/__openerp__.py
  4. 1
      mail_archives/models/__init__.py
  5. 56
      mail_archives/static/src/js/archives.js
  6. 19
      mail_archives/static/src/xml/menu.xml
  7. 12
      mail_archives/views/templates.xml
  8. 12
      mail_base/README.rst
  9. 1
      mail_base/__init__.py
  10. 22
      mail_base/__openerp__.py
  11. 1083
      mail_base/static/src/js/base.js
  12. 12
      mail_base/views/templates.xml
  13. 4
      res_partner_mails_count/README.rst
  14. 2
      res_partner_mails_count/models.py
  15. 20
      res_partner_mails_count/static/src/js/main.js
  16. 22
      res_partner_mails_count/templates.xml
  17. 2
      res_partner_mails_count/views/res_partner_mails_count.xml

15
mail_archives/README.rst

@ -0,0 +1,15 @@
Mail Archives
=============
Adds Archive menu, which shows all messages
Usage
-----
Click Messaing/Arhive menu -- all messages are displayed
Further information
-------------------
HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_archives/
Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee

3
mail_archives/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

26
mail_archives/__openerp__.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
{
"name": "mail_archives",
"summary": """Create archive channel""",
"category": "Uncategorized",
"images": [],
"version": "1.0.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
"depends": [
"base",
"mail",
"mail_base"
],
"data": [
"views/templates.xml",
],
"qweb": [
"static/src/xml/menu.xml",
],
'installable': True,
}

1
mail_archives/models/__init__.py

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

56
mail_archives/static/src/js/archives.js

@ -0,0 +1,56 @@
odoo.define('mail_archives.archives', function (require) {
"use strict";
var base_obj = require('mail_base.base');
//-------------------------------------------------------------------------------
var bus = require('bus.bus').bus;
var config = require('web.config');
var core = require('web.core');
var data = require('web.data');
var Model = require('web.Model');
var session = require('web.session');
var time = require('web.time');
var web_client = require('web.web_client');
var _t = core._t;
//-------------------------------------------------------------------------------
// Inherit class and override methods
base_obj.MailTools.include({
get_properties: function(msg){
var properties = this._super.apply(this, arguments);
properties.is_archive = this.property_descr("channel_archive", msg, this);
return properties;
},
set_channel_flags: function(data, msg){
this._super.apply(this, arguments);
msg.is_archive = true;
return msg;
},
get_channel_array: function(msg){
var arr = this._super.apply(this, arguments);
return arr.concat('channel_archive');
},
get_domain: function(channel){
return (channel.id === "channel_archive") ? [] : this._super.apply(this, arguments);
}
});
base_obj.chat_manager.is_ready.then(function(){
// Add archive channel
base_obj.chat_manager.mail_tools.add_channel({
id: "channel_archive",
name: _t("Archive"),
type: "static"
});
return $.when();
});
return base_obj.chat_manager;
});

19
mail_archives/static/src/xml/menu.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<!--Inherit Sidebar and add Archive menu item after Starred -->
<t t-extend="mail.chat.Sidebar">
<t t-jquery="div[data-channel-id=channel_starred]" t-operation="after">
<div t-attf-class="o_mail_chat_channel_item #{(active_channel_id == 'channel_archive') ? 'o_active': ''}" data-channel-id="channel_archive">
<span class="o_channel_name"> <i class="fa fa-archive"/> Archive </span>
</div>
</t>
</t>
<!--Add message about empty archive page-->
<t t-extend="mail.EmptyChannel">
<t t-jquery="t:last-child" t-operation="after">
<t t-if="options.channel_id==='channel_archive'">
<div class="o_thread_title">Archive is empty</div>
</t>
</t>
</t>
</template>

12
mail_archives/views/templates.xml

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

12
mail_base/README.rst

@ -0,0 +1,12 @@
Mail Base
=========
Modules doesn't introduce new features, but make built-in mail js features extendable.
Usage
-----
To use this module you need either install module that depends on it or create new module.
Further information
-------------------
Due to odoo restrictions, module makes mail initialization again. That is browser loads emoji and other chat data twice. This is the only way to make Mail feature extendable.

1
mail_base/__init__.py

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

22
mail_base/__openerp__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
{
"name": "Mail Base",
"summary": """Makes Mail extendable""",
"category": "Discuss",
"images": [],
"version": "1.0.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"website": "https://it-projects.info",
"license": "LGPL-3",
"depends": [
"base",
"mail"
],
"data": [
"views/templates.xml",
],
'installable': True,
}

1083
mail_base/static/src/js/base.js
File diff suppressed because it is too large
View File

12
mail_base/views/templates.xml

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

4
res_partner_mails_count/README.rst

@ -11,6 +11,6 @@ You can see Smart buttons "Mails from" and "Mails to" in the contact form in the
Further information
-------------------
HTML Description: https://apps.odoo.com/apps/modules/8.0/res_partner_mails_count/
HTML Description: https://apps.odoo.com/apps/modules/9.0/res_partner_mails_count/
Tested on Odoo 8.0 5209f6d2f26a38f66c063f05d32a962974741f40
Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee

2
res_partner_mails_count/models.py

@ -11,7 +11,7 @@ class res_partner(models.Model):
@api.one
def _mails_to(self):
for r in self:
r.mails_to = self.env['mail.message'].sudo().search_count([('notified_partner_ids', 'in', r.id)])
r.mails_to = self.env['mail.message'].sudo().search_count([('partner_ids', 'in', r.id)])
@api.one
def _mails_from(self):

20
res_partner_mails_count/static/src/js/main.js

@ -1,10 +1,10 @@
openerp.res_partner_mails_count = function(instance){
instance.mail.Wall.include({
init: function(){
this._super.apply(this, arguments);
if(this.context.ignore_search_model){
delete this.defaults.model;
}
}
});
};
// openerp.res_partner_mails_count = function(instance){
// instance.mail.Wall.include({
// init: function(){
// this._super.apply(this, arguments);
// if(this.context.ignore_search_model){
// delete this.defaults.model;
// }
// }
// });
// };

22
res_partner_mails_count/templates.xml

@ -10,38 +10,26 @@
</xpath>
</template>
<record id="search_notified_partner_ids" model="ir.ui.view">
<field name="name">mail.message.search.notified_partner</field>
<field name="model">mail.message</field>
<field name="priority">50</field>
<field name="inherit_id" ref="mail.view_message_search"/>
<field name="arch" type="xml">
<search string="Messages Search">
<field name="notified_partner_ids"/>
</search>
</field>
</record>
<record id="view_res_partner_mails_count_info_form" model="ir.ui.view">
<field name="name">res.partner.mails.count</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority" eval="50"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" type="action"
<div name="button_box" position="inside">
<button class="oe_stat_button" type="action"
name="%(action_mails)d"
context="{'search_default_notified_partner_ids': [active_id], 'default_model': 'res.partner', 'default_res_id': active_id}"
context="{'search_default_partner_ids': [active_id], 'default_model': 'res.partner', 'default_res_id': active_id}"
icon="fa-envelope">
<field string="Mails to" name="mails_to" widget="statinfo"/>
</button>
<button class="oe_inline oe_stat_button" type="action"
<button class="oe_stat_button" type="action"
name="%(action_mails)d"
context="{'search_default_author_id': active_id, 'default_model': 'res.partner', 'default_res_id': active_id}"
icon="fa-envelope-o">
<field string="Mails from" name="mails_from" widget="statinfo"/>
</button>
</xpath>
</div>
</field>
</record>
</data>

2
res_partner_mails_count/views/res_partner_mails_count.xml

@ -3,7 +3,7 @@
<data>
<record id="action_mails" model="ir.actions.client">
<field name="name">Mails</field>
<field name="tag">mail.wall</field>
<field name="tag">mail.chat.instant_messaging</field>
<field name="res_model">mail.message</field>
<field name="context">{
'ignore_search_model': True,

Loading…
Cancel
Save