diff --git a/mail_archives/README.rst b/mail_archives/README.rst new file mode 100644 index 0000000..100ef14 --- /dev/null +++ b/mail_archives/README.rst @@ -0,0 +1,15 @@ +Mail Archives +============= + +Display archive channel which contain read messages + +Usage +----- +Click by archive menu item and receive read messages (having attribute read = true) + +Further information +------------------- + +HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_archives/ + +Tested on Odoo 9.0 \ No newline at end of file diff --git a/mail_archives/__init__.py b/mail_archives/__init__.py new file mode 100644 index 0000000..5305644 --- /dev/null +++ b/mail_archives/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models \ No newline at end of file diff --git a/mail_archives/__openerp__.py b/mail_archives/__openerp__.py new file mode 100644 index 0000000..316de3e --- /dev/null +++ b/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": "http://www.it-projects.info", + "license": "LGPL-3", + + "depends": [ + "base", + "mail" + ], + + "data": [ + "views/views.xml", + "views/templates.xml", + ], + "qweb": [ + "static/src/xml/menu.xml", + ], + 'installable': True, +} diff --git a/mail_archives/models/__init__.py b/mail_archives/models/__init__.py new file mode 100644 index 0000000..5305644 --- /dev/null +++ b/mail_archives/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models \ No newline at end of file diff --git a/mail_archives/models/models.py b/mail_archives/models/models.py new file mode 100644 index 0000000..a3a40fa --- /dev/null +++ b/mail_archives/models/models.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +from openerp import models, fields, api + +# class mail_arhives(models.Model): +# _name = 'mail_arhives.mail_arhives' + +# name = fields.Char() +# value = fields.Integer() +# value2 = fields.Float(compute="_value_pc", store=True) +# description = fields.Text() +# +# @api.depends('value') +# def _value_pc(self): +# self.value2 = float(self.value) / 100 \ No newline at end of file diff --git a/mail_archives/static/src/js/archives.js b/mail_archives/static/src/js/archives.js new file mode 100644 index 0000000..6079f66 --- /dev/null +++ b/mail_archives/static/src/js/archives.js @@ -0,0 +1,61 @@ +odoo.define('mail_archives.archives', function (require) { +"use strict"; + +// var core = require('web.core'); +// var utils = require('web.utils'); +// var Widget = require('web.Widget'); +var Model = require('web.Model'); +var MessageModel = new Model('mail.message', session.context); + +var chat_manager = require('mail.chat_manager'); +console.log('qqq'); + +var LIMIT = 100; + +function get_channel_cache (channel, domain) { + var stringified_domain = JSON.stringify(domain || []); + if (!channel.cache[stringified_domain]) { + channel.cache[stringified_domain] = { + all_history_loaded: false, + loaded: false, + messages: [], + }; + } + return channel.cache[stringified_domain]; +} + +function fetch_from_channel (channel, options) { + options = options || {}; + var domain = + (channel.id === "channel_inbox") ? [['needaction', '=', true]] : + (channel.id === "channel_starred") ? [['starred', '=', true]] : + (channel.id === "channel_archive") ? [['read', '=', true]] : + [['channel_ids', 'in', channel.id]]; + var cache = get_channel_cache(channel, options.domain); + + if (options.domain) { + domain = new data.CompoundDomain(domain, options.domain || []); + } + if (options.load_more) { + var min_message_id = cache.messages[0].id; + domain = new data.CompoundDomain([['id', '<', min_message_id]], domain); + } + + return MessageModel.call('message_fetch', [domain], {limit: LIMIT}).then(function (msgs) { + if (!cache.all_history_loaded) { + cache.all_history_loaded = msgs.length < LIMIT; + } + cache.loaded = true; + + // _.each(msgs, function (msg) { + // add_message(msg, {channel_id: channel.id, silent: true, domain: options.domain}); + // }); + var channel_cache = get_channel_cache(channel, options.domain || []); + return channel_cache.messages; + }); +} + +//TODO: переложить все в репозиторий mail_addons-9.0-res_partner_mails_count +return chat_manager; + +}); diff --git a/mail_archives/static/src/xml/menu.xml b/mail_archives/static/src/xml/menu.xml new file mode 100644 index 0000000..c6151b9 --- /dev/null +++ b/mail_archives/static/src/xml/menu.xml @@ -0,0 +1,10 @@ + + diff --git a/mail_archives/views/templates.xml b/mail_archives/views/templates.xml new file mode 100644 index 0000000..a99a03d --- /dev/null +++ b/mail_archives/views/templates.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/mail_archives/views/views.xml b/mail_archives/views/views.xml new file mode 100644 index 0000000..dc3a5bb --- /dev/null +++ b/mail_archives/views/views.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mail_base/README.rst b/mail_base/README.rst new file mode 100644 index 0000000..ed52ea7 --- /dev/null +++ b/mail_base/README.rst @@ -0,0 +1,11 @@ +Mail Base +========= + +Module contain common code for other mail modules + +Usage +----- + + +Further information +-------------------