Browse Source
Merge pull request #3 from yelizariev/8.0-res_partner_mails_count
Merge pull request #3 from yelizariev/8.0-res_partner_mails_count
8.0 res partner mails countpull/17/head
Ivan Yelizariev
9 years ago
17 changed files with 289 additions and 0 deletions
-
16res_partner_mails_count/README.rst
-
2res_partner_mails_count/__init__.py
-
29res_partner_mails_count/__openerp__.py
-
BINres_partner_mails_count/images/1.png
-
19res_partner_mails_count/models.py
-
BINres_partner_mails_count/static/description/1.png
-
BINres_partner_mails_count/static/description/2.png
-
BINres_partner_mails_count/static/description/3.png
-
BINres_partner_mails_count/static/description/icon.png
-
34res_partner_mails_count/static/description/index.html
-
10res_partner_mails_count/static/src/js/main.js
-
46res_partner_mails_count/static/src/js/res_partner_mails_count_tour.js
-
60res_partner_mails_count/templates.xml
-
4res_partner_mails_count/tests/__init__.py
-
33res_partner_mails_count/tests/test_mail.py
-
18res_partner_mails_count/tests/test_phantom.py
-
18res_partner_mails_count/views/res_partner_mails_count.xml
@ -0,0 +1,16 @@ |
|||
Smart buttons for mails count |
|||
============================= |
|||
|
|||
This module adds Smart buttons with "Mails from" and "Mails to" count of mails in the partner form. |
|||
|
|||
Usage |
|||
----- |
|||
|
|||
You can see Smart buttons "Mails from" and "Mails to" in the contact form in the Messaging/Contacts menu. If you click on these buttons, you can see list of corresponded mails. Click on the "Send a message" link to send mail to the partner. |
|||
|
|||
Further information |
|||
------------------- |
|||
|
|||
HTML Description: https://apps.odoo.com/apps/modules/8.0/res_partner_mails_count/ |
|||
|
|||
Tested on Odoo 8.0 5209f6d2f26a38f66c063f05d32a962974741f40 |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
import models |
@ -0,0 +1,29 @@ |
|||
# -*- coding: utf-8 -*- |
|||
{ |
|||
"name": """Partner mails count""", |
|||
"summary": """Displays amount of incoming and outgoing partner mails.""", |
|||
"category": "Sales Management", |
|||
"images": ['images/1.png'], |
|||
"version": "1.0.0", |
|||
|
|||
"author": "IT-Projects LLC", |
|||
"website": "https://it-projects.info", |
|||
"license": "GPL-3", |
|||
"price": 30.00, |
|||
"currency": "EUR", |
|||
|
|||
"depends": [ |
|||
'base', |
|||
'mail' , |
|||
'web_tour_extra' , |
|||
], |
|||
"external_dependencies": {"python": [], "bin": []}, |
|||
"data": [ |
|||
'views/res_partner_mails_count.xml', |
|||
'templates.xml', |
|||
], |
|||
"demo": [ |
|||
], |
|||
"installable": True, |
|||
"auto_install": False, |
|||
} |
After Width: 1128 | Height: 528 | Size: 92 KiB |
@ -0,0 +1,19 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from openerp import models, fields, api |
|||
|
|||
|
|||
class res_partner(models.Model): |
|||
_inherit = 'res.partner' |
|||
mails_to = fields.Integer(compute="_mails_to") |
|||
mails_from = fields.Integer(compute="_mails_from") |
|||
|
|||
@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)]) |
|||
|
|||
@api.one |
|||
def _mails_from(self): |
|||
for r in self: |
|||
r.mails_from = self.env['mail.message'].sudo().search_count([('author_id', '=', r.id)]) |
After Width: 1128 | Height: 528 | Size: 92 KiB |
After Width: 1128 | Height: 528 | Size: 91 KiB |
After Width: 1128 | Height: 528 | Size: 77 KiB |
After Width: 100 | Height: 100 | Size: 2.1 KiB |
@ -0,0 +1,34 @@ |
|||
<section class="oe_container"> |
|||
<div class="oe_row oe_spaced"> |
|||
<div class="oe_span12"> |
|||
<h2 class="oe_slogan">Smart buttons for mails count</h2> |
|||
<h3 class="oe_slogan">Display amount of messages from/to customer</h3> |
|||
<p> |
|||
Open partner (customer) form and look up how many messages he got and sent: |
|||
<img class="oe_picture oe_screenshot" src="1.png"/> |
|||
</p> |
|||
<p> |
|||
If you click any of this buttons: |
|||
<img class="oe_picture oe_screenshot" src="2.png"/> |
|||
</p> |
|||
<p> |
|||
You will see those mails: |
|||
<img class="oe_picture oe_screenshot" src="3.png"/> |
|||
</p> |
|||
</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> |
@ -0,0 +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; |
|||
} |
|||
} |
|||
}); |
|||
}; |
@ -0,0 +1,46 @@ |
|||
(function () { |
|||
'use strict'; |
|||
|
|||
var _t = openerp._t; |
|||
|
|||
openerp.Tour.register({ |
|||
id: 'mails_count_tour', |
|||
name: _t("Mails count Tour"), |
|||
mode: 'test', |
|||
path: '/web?res_partner_mails_count=tutorial#id=3&view_type=form&model=res.partner', |
|||
// mode: 'tutorial',
|
|||
steps: [ |
|||
{ |
|||
title: _t("Mails count tutorial"), |
|||
content: _t("Let's see how mails count work."), |
|||
popover: { next: _t("Start Tutorial"), end: _t("Skip") }, |
|||
}, |
|||
{ |
|||
title: _t("New fields"), |
|||
content: _t("Here is new fields with mails counters. Press one of it."), |
|||
element: '.mails_to', |
|||
|
|||
}, |
|||
{ |
|||
waitNot: '.mails_to:visible', |
|||
title: _t("Send message from here"), |
|||
placement: 'left', |
|||
content: _t("Now you can see corresponding mails. You can send mail to this partner right from here. Press <em>'Send a mesage'</em>."), |
|||
element: '.oe_mail_wall .oe_msg.oe_msg_composer_compact>div>.oe_compose_post', |
|||
}, |
|||
{ |
|||
title: "New message", |
|||
placement: 'left', |
|||
content: _t("You can type message here."), |
|||
element: 'div.oe_msg_content>textarea.field_text', |
|||
}, |
|||
{ |
|||
wait: '7000', |
|||
title: "That's it", |
|||
content: _t("Enjoy your day! <br/> <br/><a href='https://www.it-projects.info/apps' target='_blank'>IT-Projects LLC</a> team "), |
|||
popover: { next: _t("Close Tutorial") }, |
|||
}, |
|||
] |
|||
}); |
|||
|
|||
}()); |
@ -0,0 +1,60 @@ |
|||
<?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="/res_partner_mails_count/static/src/js/main.js" |
|||
type="text/javascript"></script> |
|||
<script src="/res_partner_mails_count/static/src/js/res_partner_mails_count_tour.js" |
|||
type="text/javascript"></script> |
|||
</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 mails_to" type="action" |
|||
name="%(action_mails)d" |
|||
context="{'search_default_notified_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 mails_from" 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> |
|||
</field> |
|||
</record> |
|||
<record id="res_partner_mails_count_tutorial" model="ir.actions.act_url"> |
|||
<field name="name">res_partner_mails_count Tutorial</field> |
|||
<field name="url" eval="'/web?debug=1&res_partner_mails_count=tutorial#id='+str(ref('base.partner_root'))+'&view_type=form&model=res.partner&/#tutorial_extra.mails_count_tour=true'"/> |
|||
<field name="target">self</field> |
|||
</record> |
|||
<record id="base.open_menu" model="ir.actions.todo"> |
|||
<field name="action_id" ref="res_partner_mails_count_tutorial"/> |
|||
<field name="state">open</field> |
|||
<field name="sequence">200</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import test_mail |
|||
from . import test_phantom |
@ -0,0 +1,33 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from openerp.tests.common import TransactionCase |
|||
|
|||
|
|||
class test_message_count(TransactionCase): |
|||
post_install = True |
|||
def test_count(self): |
|||
new_partner1 = self.env['res.partner'].sudo().create({'name': 'rpmc Test Partner one', 'email': 'tt@tt', 'notify_email': 'always'}) |
|||
new_partner2 = self.env['res.partner'].sudo().create({'name': 'rpmc Test Partner two', 'email': 'rr@rr', 'notify_email': 'always'}) |
|||
self.assertEqual(new_partner1.mails_to, 0, 'rpmc: new partner have mails_to != 0') |
|||
mail_compose = self.env['mail.compose.message'] |
|||
compose = mail_compose.with_context( |
|||
{ |
|||
'default_composition_mode': 'comment', |
|||
}).create( |
|||
{ |
|||
'subject': 'test subj', |
|||
'body': 'test body', |
|||
'partner_ids': [(4, new_partner2.id)], |
|||
'email_from': 'tt@tt', |
|||
'author_id': new_partner1.id |
|||
}) |
|||
compose.send_mail() |
|||
self.assertEqual(new_partner1.mails_to, 0) |
|||
self.assertEqual(new_partner1.mails_from, 1, 'rpmc: one message but mails_from != 1') |
|||
self.assertEqual(new_partner2.mails_to, 1, 'rpmc: one message but mails_to != 1') |
|||
self.assertEqual(new_partner2.mails_from, 0) |
|||
compose.send_mail() |
|||
self.assertEqual(new_partner1.mails_to, 0) |
|||
self.assertEqual(new_partner1.mails_from, 2, 'rpmc: one message but mails_from != 2') |
|||
self.assertEqual(new_partner2.mails_to, 2, 'rpmc: one message but mails_to != 2') |
|||
self.assertEqual(new_partner2.mails_from, 0) |
@ -0,0 +1,18 @@ |
|||
import openerp.tests |
|||
|
|||
@openerp.tests.common.at_install(False) |
|||
@openerp.tests.common.post_install(True) |
|||
class TestUi(openerp.tests.HttpCase): |
|||
def test_01_res_partner_mails_to_count(self): |
|||
self.phantom_js('/', "openerp.Tour.run('mails_count_tour', 'test')", "openerp.Tour.tours.mails_count_tour", login="admin") |
|||
|
|||
def test_02_res_partner_mails_from_count(self): |
|||
# wait till page loaded and then click and wait again |
|||
code = """ |
|||
setTimeout(function () { |
|||
$(".mails_from").click(); |
|||
setTimeout(function () {console.log('ok');}, 3000); |
|||
}, 3000); |
|||
""" |
|||
link = '/web#id=3&view_type=form&model=res.partner' |
|||
self.phantom_js(link, code, "openerp.Tour.tours.mails_count_tour", login="admin") |
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
<record id="action_mails" model="ir.actions.client"> |
|||
<field name="name">Mails</field> |
|||
<field name="tag">mail.wall</field> |
|||
<field name="res_model">mail.message</field> |
|||
<field name="context">{ |
|||
'ignore_search_model': True, |
|||
}</field> |
|||
<field name="help" type="html"> |
|||
<p> |
|||
Mails not found. Probably, they exist, but you don't have access. |
|||
</p> |
|||
</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue