Browse Source

Add mail_archive module in current repo.

Create mail_base dir for future module
which contain common code for other modules.
pull/6/head
x620 9 years ago
parent
commit
621ed51475
  1. 15
      mail_archives/README.rst
  2. 3
      mail_archives/__init__.py
  3. 26
      mail_archives/__openerp__.py
  4. 3
      mail_archives/models/__init__.py
  5. 15
      mail_archives/models/models.py
  6. 61
      mail_archives/static/src/js/archives.js
  7. 10
      mail_archives/static/src/xml/menu.xml
  8. 12
      mail_archives/views/templates.xml
  9. 59
      mail_archives/views/views.xml
  10. 11
      mail_base/README.rst

15
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

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": "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,
}

3
mail_archives/models/__init__.py

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

15
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

61
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;
});

10
mail_archives/static/src/xml/menu.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<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>
</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>

59
mail_archives/views/views.xml

@ -0,0 +1,59 @@
<openerp>
<data>
<!-- explicit list view definition -->
<!--
<record model="ir.ui.view" id="mail_arhives.list">
<field name="name">mail_arhives list</field>
<field name="model">mail_arhives.mail_arhives</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="value"/>
<field name="value2"/>
</tree>
</field>
</record>
-->
<!-- actions opening views on models -->
<!--
<record model="ir.actions.act_window" id="mail_arhives.action_window">
<field name="name">mail_arhives window</field>
<field name="res_model">mail_arhives.mail_arhives</field>
<field name="view_mode">tree,form</field>
</record>
-->
<!-- server action to the one above -->
<!--
<record model="ir.actions.server" id="mail_arhives.action_server">
<field name="name">mail_arhives server</field>
<field name="model_id" ref="model_mail_arhives_mail_arhives"/>
<field name="code">
action = {
"type": "ir.actions.act_window",
"view_mode": "tree,form",
"res_model": self._name,
}
</field>
</record>
-->
<!-- Top menu item -->
<!--
<menuitem name="mail_arhives" id="mail_arhives.menu_root"/>
-->
<!-- menu categories -->
<!--
<menuitem name="Menu 1" id="mail_arhives.menu_1" parent="mail_arhives.menu_root"/>
<menuitem name="Menu 2" id="mail_arhives.menu_2" parent="mail_arhives.menu_root"/>
-->
<!-- actions -->
<!--
<menuitem name="List" id="mail_arhives.menu_1_list" parent="mail_arhives.menu_1"
action="mail_arhives.action_window"/>
<menuitem name="Server to list" id="mail_arhives" parent="mail_arhives.menu_2"
action="mail_arhives.action_server"/>
-->
</data>
</openerp>

11
mail_base/README.rst

@ -0,0 +1,11 @@
Mail Base
=========
Module contain common code for other mail modules
Usage
-----
Further information
-------------------
Loading…
Cancel
Save