Browse Source

Show smart buttons and calculate mails count.

notified_partner_ids was removed in 9.0, so it changed to partner_ids.
pull/6/head
x620 9 years ago
parent
commit
471f5f4ce8
  1. 2
      res_partner_mails_count/models.py
  2. 26
      res_partner_mails_count/static/src/js/main.js
  3. 22
      res_partner_mails_count/templates.xml
  4. 16
      res_partner_mails_count/views/res_partner_mails_count.xml

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([('notified_partner_ids', 'in', r.id)])
r.mails_to = self.env['mail.message'].sudo().search_count([('partner_ids', 'in', r.id)])
@api.one @api.one
def _mails_from(self): def _mails_from(self):

26
res_partner_mails_count/static/src/js/main.js

@ -1,10 +1,16 @@
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;
// }
// }
// });
// };
// odoo.define('res_partner_mails_count.main', function(require) {
// "use strict";
//
// });

22
res_partner_mails_count/templates.xml

@ -10,38 +10,26 @@
</xpath> </xpath>
</template> </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"> <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"/>
<field name="priority" eval="50"/> <field name="priority" eval="50"/>
<field name="arch" type="xml"> <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" 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"> 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_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">
<field string="Mails from" name="mails_from" widget="statinfo"/> <field string="Mails from" name="mails_from" widget="statinfo"/>
</button> </button>
</xpath>
</div>
</field> </field>
</record> </record>
</data> </data>

16
res_partner_mails_count/views/res_partner_mails_count.xml

@ -3,7 +3,7 @@
<data> <data>
<record id="action_mails" model="ir.actions.client"> <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.chat.instant_messaging</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,
@ -14,5 +14,19 @@
</p> </p>
</field> </field>
</record> </record>
<!--<record id="action_mails" model="ir.actions.act_window">-->
<!--<field name="name">Mails</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> </data>
</openerp> </openerp>
Loading…
Cancel
Save