Browse Source

Merge pull request #31 from x620/mail-addons-8.0-res_partner_mails_count

[FIX] Mail addons 8.0 res partner mails count
pull/3/head
Ivan Yelizariev 9 years ago
parent
commit
b72044fb1d
  1. 1
      res_partner_mails_count/__init__.py
  2. 4
      res_partner_mails_count/__openerp__.py
  3. 20
      res_partner_mails_count/controllers.py
  4. 25
      res_partner_mails_count/demo.xml
  5. 2
      res_partner_mails_count/models.py
  6. 2
      res_partner_mails_count/security/ir.model.access.csv
  7. 23
      res_partner_mails_count/templates.xml
  8. 2
      res_partner_mails_count/tests/test_mail.py
  9. 8
      res_partner_mails_count/views/res_partner_mails_count.xml

1
res_partner_mails_count/__init__.py

@ -1,3 +1,2 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import controllers
import models import models

4
res_partner_mails_count/__openerp__.py

@ -28,8 +28,4 @@
'views/res_partner_mails_count.xml', 'views/res_partner_mails_count.xml',
'templates.xml', 'templates.xml',
], ],
# only loaded in demonstration mode
'demo': [
'demo.xml',
],
} }

20
res_partner_mails_count/controllers.py

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
from openerp import http
# class ResPartnerMailsCount(http.Controller):
# @http.route('/res_partner_mails_count/res_partner_mails_count/', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/res_partner_mails_count/res_partner_mails_count/objects/', auth='public')
# def list(self, **kw):
# return http.request.render('res_partner_mails_count.listing', {
# 'root': '/res_partner_mails_count/res_partner_mails_count',
# 'objects': http.request.env['res_partner_mails_count.res_partner_mails_count'].search([]),
# })
# @http.route('/res_partner_mails_count/res_partner_mails_count/objects/<model("res_partner_mails_count.res_partner_mails_count"):obj>/', auth='public')
# def object(self, obj, **kw):
# return http.request.render('res_partner_mails_count.object', {
# 'object': obj
# })

25
res_partner_mails_count/demo.xml

@ -1,25 +0,0 @@
<openerp>
<data>
<!-- -->
<!-- <record id="object0" model="res_partner_mails_count.res_partner_mails_count"> -->
<!-- <field name="name">Object 0</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object1" model="res_partner_mails_count.res_partner_mails_count"> -->
<!-- <field name="name">Object 1</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object2" model="res_partner_mails_count.res_partner_mails_count"> -->
<!-- <field name="name">Object 2</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object3" model="res_partner_mails_count.res_partner_mails_count"> -->
<!-- <field name="name">Object 3</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object4" model="res_partner_mails_count.res_partner_mails_count"> -->
<!-- <field name="name">Object 4</field> -->
<!-- </record> -->
<!-- -->
</data>
</openerp>

2
res_partner_mails_count/models.py

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

2
res_partner_mails_count/security/ir.model.access.csv

@ -1,2 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_res_partner_mails_count_res_partner_mails_count,res_partner_mails_count.res_partner_mails_count,model_res_partner_mails_count_res_partner_mails_count,,1,0,0,0

23
res_partner_mails_count/templates.xml

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<openerp> <openerp>
<data> <data>
<template id="res_partner_mails_count_assets_backend"
<template id="res_partner_mails_count_assets_backend"
name="res_partner_mails_count_assets_backend" name="res_partner_mails_count_assets_backend"
inherit_id="web.assets_backend"> inherit_id="web.assets_backend">
<xpath expr="." position="inside"> <xpath expr="." position="inside">
@ -9,7 +9,20 @@
type="text/javascript"></script> type="text/javascript"></script>
</xpath> </xpath>
</template> </template>
<record id="view_res_partner_mails_count_info_form" model="ir.ui.view">
<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="name">res.partner.mails.count</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/> <field name="inherit_id" ref="base.view_partner_form"/>
@ -18,11 +31,11 @@
<xpath expr="//div[@name='buttons']" position="inside"> <xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" type="action" <button class="oe_inline oe_stat_button" type="action"
name="%(action_mails)d" name="%(action_mails)d"
context="{'search_default_partner_ids': [active_id], 'default_model': 'res.partner', 'default_res_id': active_id}"
context="{'search_default_notified_partner_ids': [active_id], 'default_model': 'res.partner', 'default_res_id': active_id}"
icon="fa-envelope"> icon="fa-envelope">
<field string="Mails to" name="mails_to" widget="statinfo"/> <field string="Mails to" name="mails_to" widget="statinfo"/>
</button> </button>
<button class="oe_inline oe_stat_button" type="action"
<button class="oe_inline oe_stat_button" type="action"
name="%(action_mails)d" name="%(action_mails)d"
context="{'search_default_author_id': active_id, 'default_model': 'res.partner', 'default_res_id': active_id}" context="{'search_default_author_id': active_id, 'default_model': 'res.partner', 'default_res_id': active_id}"
icon="fa-envelope-o"> icon="fa-envelope-o">
@ -32,4 +45,4 @@
</field> </field>
</record> </record>
</data> </data>
</openerp>
</openerp>

2
res_partner_mails_count/tests/test_mail.py

@ -13,8 +13,6 @@ class test_message_count(TransactionCase):
compose = mail_compose.with_context( compose = mail_compose.with_context(
{ {
'default_composition_mode': 'comment', 'default_composition_mode': 'comment',
'default_model': 'res.partner',
'default_res_id': new_partner1.id,
}).create( }).create(
{ {
'subject': 'test subj', 'subject': 'test subj',

8
res_partner_mails_count/views/res_partner_mails_count.xml

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<openerp> <openerp>
<data>
<record id="action_mails" model="ir.actions.client">
<data>
<record id="action_mails" model="ir.actions.client">
<field name="name">Mails</field> <field name="name">Mails</field>
<field name="tag">mail.wall</field> <field name="tag">mail.wall</field>
<field name="res_model">mail.message</field> <field name="res_model">mail.message</field>
<field name="context">{ <field name="context">{
'ignore_search_model': True,
'ignore_search_model': True,
}</field> }</field>
<field name="help" type="html"> <field name="help" type="html">
<p> <p>
@ -14,5 +14,5 @@
</p> </p>
</field> </field>
</record> </record>
</data>
</data>
</openerp> </openerp>
Loading…
Cancel
Save