Browse Source

Switch from and to

pull/3/head
x620 9 years ago
parent
commit
faa0351324
  1. 10
      res_partner_mails_count/models.py
  2. 8
      res_partner_mails_count/templates.xml
  3. 22
      res_partner_mails_count/views/res_partner_mails_count.xml

10
res_partner_mails_count/models.py

@ -5,15 +5,15 @@ from openerp import models, fields, api
class res_partner(models.Model): class res_partner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
mails_from = fields.Integer(compute="_mails_from")
mails_to = fields.Integer(compute="_mails_to") mails_to = fields.Integer(compute="_mails_to")
mails_from = fields.Integer(compute="_mails_from")
@api.one @api.one
def _mails_from(self):
def _mails_to(self):
for r in self: for r in self:
r.mails_from = self.env['mail.message'].sudo().search_count([('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_to(self):
def _mails_from(self):
for r in self: for r in self:
r.mails_to = self.env['mail.message'].sudo().search_count([('author_id', '=', r.id)])
r.mails_from = self.env['mail.message'].sudo().search_count([('author_id', '=', r.id)])

8
res_partner_mails_count/templates.xml

@ -9,16 +9,16 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<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_from)d"
name="%(action_mails)d"
context="{'search_default_partner_ids': [active_id]}" context="{'search_default_partner_ids': [active_id]}"
icon="fa-envelope"> icon="fa-envelope">
<field string="Mails from" name="mails_from" 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_to)d"
name="%(action_mails)d"
context="{'search_default_author_id': active_id}" context="{'search_default_author_id': active_id}"
icon="fa-envelope-o"> icon="fa-envelope-o">
<field string="Mails to" name="mails_to" widget="statinfo"/>
<field string="Mails from" name="mails_from" widget="statinfo"/>
</button> </button>
</xpath> </xpath>
</field> </field>

22
res_partner_mails_count/views/res_partner_mails_count.xml

@ -1,29 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<openerp> <openerp>
<data> <data>
<record id="action_mails_from" model="ir.actions.act_window">
<field name="name">Mails from</field>
<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="res_model">mail.message</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="context">{ <field name="context">{
'active_test': False,
'ignore_search_model': True,
}</field> }</field>
<field name="help" type="html"> <field name="help" type="html">
<p> <p>
Mails from
</p>
</field>
</record>
<record id="action_mails_to" model="ir.actions.act_window">
<field name="name">Mails to</field>
<field name="res_model">mail.message</field>
<field name="view_mode">tree,form</field>
<field name="context">{
'active_test': False,
}</field>
<field name="help" type="html">
<p>
Mails to
Mails not found. Probably, they exist, but you don't have access.
</p> </p>
</field> </field>
</record> </record>

Loading…
Cancel
Save