فهرست منبع

Modulo crm_mensaje

sebas 8 سال پیش
کامیت
2062af3574
14فایلهای تغییر یافته به همراه725 افزوده شده و 0 حذف شده
  1. 26 0
      __init__.py
  2. BIN
      __init__.pyc
  3. 66 0
      __openerp__.py
  4. 48 0
      crm_lead.py
  5. BIN
      crm_lead.pyc
  6. 75 0
      crm_lead_view.xml
  7. 134 0
      crm_mensaje.py
  8. BIN
      crm_mensaje.pyc
  9. 43 0
      crm_mensaje_menu.xml
  10. 95 0
      crm_mensaje_view.xml
  11. 86 0
      informe_crm_mensaje.xml
  12. 107 0
      res_partner.py
  13. 45 0
      res_partner_view.xml
  14. BIN
      static/description/icon.png

+ 26 - 0
__init__.py

@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import crm_mensaje
+import crm_lead
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
__init__.pyc


+ 66 - 0
__openerp__.py

@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+    'name': 'CRM Mensajes',
+    'version': '1.0',
+    'category': 'Registro de mensajes',
+    'sequence': 2,
+    'summary': 'Mensajes',
+    'description': """
+Registro de Mensajes
+====================================================
+
+Esta aplicación se utiliza para registrar los datos más importantes de una conversación por medio de mensajes con el cliente.
+
+Los datos registrados son: el asunto, la fecha y hora, el cliente, etc.
+
+""",
+    'author': 'Sebastian Penayo/Eiru Software',
+    'website': 'https://www.eiru.com.py',
+    'depends': [
+        'base_action_rule',
+        'base_setup',
+        'sales_team',
+        'mail',
+        'email_template',
+        'crm',
+        'resource',
+        'board',
+        'fetchmail',
+    ],
+    'data': [
+        'crm_mensaje_view.xml',
+        'crm_lead_view.xml',
+        'crm_mensaje_menu.xml',
+		'res_partner_view.xml',
+		'informe_crm_mensaje.xml',
+    ],
+    'demo': [
+    ],
+    'test': [
+    ],
+    'installable': True,
+    'application': True,
+    'auto_install': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 48 - 0
crm_lead.py

@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+from datetime import datetime
+from operator import itemgetter
+
+import openerp
+from openerp import SUPERUSER_ID
+from openerp import tools
+from openerp.osv import fields, osv, orm
+from openerp.tools.translate import _
+
+
+class crm_lead(osv.osv):
+    _inherit = 'crm.lead'
+
+    def _messenger_count(self, cr, uid, ids, field_name, arg, context=None):
+        Event = self.pool['crm.mensaje']
+        return {
+            opportunity_id: Event.search_count(cr,uid, [('opportunity_id', '=', opportunity_id)], context=context)
+            for opportunity_id in ids
+        }
+    _columns = {
+        'messenger_count': fields.function(_messenger_count, string='# Mensaje', type='integer'),
+    }
+
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
crm_lead.pyc


+ 75 - 0
crm_lead_view.xml

@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+
+        <!--
+            OPPORTUNITY
+
+
+        <record id="relate_partner_leads" model="ir.actions.act_window">
+          <field name="name">Iniciativas</field>
+          <field name="res_model">crm.lead</field>
+          <field name="view_mode">tree,form</field>
+          <field name="domain">[('type','=','lead')]</field>
+          <field name="context">{
+              'search_default_partner_id': active_id,
+              'stage_type': 'lead',
+              'default_type': 'lead'
+          }</field>
+          <field name="view_id" eval="False"/>
+          <field name="search_view_id" ref="crm.view_crm_case_leads_filter"/>
+          <field name="help" type="html">
+            <p class="oe_view_nocontent_create">
+              Click to create an lead related to this customer.
+            </p><p>
+              Use leads to keep track of your sales pipeline, follow
+              up potential sales and better forecast your future revenues.
+            </p><p>
+              You will be able to plan meetings and phone calls from
+              leads, convert them into quotations, attach related
+              documents, track all discussions, and much more.
+            </p>
+          </field>
+        </record>   -->
+
+        <record id="crm_case_categ_mensaje2" model="ir.actions.act_window">
+               <field name="name">Mensajes</field>
+               <field name="res_model">crm.mensaje</field>
+               <field name="view_type">form</field>
+               <field name="view_mode">tree,form</field>
+               <field name="context">{'default_opportunity_id': active_id}</field>
+               <field name="help" type="html">
+                 <p class="oe_view_nocontent_create">
+                   Click para crear un mensaje recibido para una oportunidad de venta.
+                 </p><p>
+                   El registro de mensaje es importante ya que acompaña para el
+                   seguimiento de iniciativas y oportunidades para la obtencion
+                   de ventas.
+                 </p>
+               </field>
+           </record>
+
+
+        <!-- Opportunities Form View ,'search_default_partner_id': active_id, 'default_partner_id': active_id-->
+        <record model="ir.ui.view" id="crm_case_form_view_oppor3">
+            <field name="name">Mensajes</field>
+            <field name="model">crm.lead</field>
+            <field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
+            <field name="priority">20</field>
+            <field name="arch" type="xml">
+
+                        <div class="oe_right oe_button_box">
+                            <button class="oe_inline oe_stat_button" type="action"
+                                name="%(crm_case_categ_mensaje2)d"
+                                context="{'default_opportunity_id': active_id, 'search_default_opportunity_id': active_id}"
+                                icon="fa-pencil-square-o">
+                                <field string="Mensaje" name="messenger_count" widget="statinfo"/>
+                            </button>
+                        </div>
+
+            </field>
+        </record>
+
+
+    </data>
+</openerp>

+ 134 - 0
crm_mensaje.py

@@ -0,0 +1,134 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from datetime import datetime
+from openerp.osv import fields, osv
+from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
+from openerp.tools.translate import _
+
+class crm_mensaje(osv.osv):
+    """ Model for CRM Mensajes """
+    _name = "crm.mensaje"
+    _description = "Mensaje"
+    _order = "id desc"
+
+    _columns = {
+		'date_action_last': fields.datetime('Accion Anterior', readonly=1),
+		'date_action_next': fields.datetime('Fecha Prox. Accion', readonly=True),
+		'action_next': fields.char('Prox. Accion'),
+		'create_date': fields.datetime('Fecha Creado' , readonly=True),
+		'user_id': fields.many2one('res.users', 'Responsable'),
+		'partner_id': fields.many2one('res.partner', 'Cliente'),
+		'company_id': fields.many2one('res.company', 'Compania'),
+		'description': fields.text('Descripcion'),
+		'state': fields.selection(
+			[('open', 'Abierto'),
+             ('cancel', 'Cancelado'),
+             ('pending', 'Pendiente'),
+             ('done', 'Realizado')
+             ], string='Estado', readonly=True, track_visibility='onchange',
+            help='El estado se establece en Abierto, cuando se crea un caso.\n'
+                 'Cuando la convesacion termina, el estado se establece en Realizada.\n'
+                 'Si las llamadas no es aplicable más, el estado se puede configurar para Cancelado.'),
+        'date_open': fields.datetime('Fecha Abierto', readonly=True),
+        # phonecall fields
+        'name': fields.char('Resumen del mensaje', required=True),
+        'active': fields.boolean('Activo', required=False),
+        'partner_phone': fields.char('Celular1'),
+        'partner_mobile': fields.char('Celular2'),
+        'priority': fields.selection([('0','P'), ('1','Poco'),('2','Normal'), ('3','Alto')], 'Prioridad'),
+        'date_closed': fields.datetime('Cerrado', readonly=True),
+		'opportunity_id': fields.many2one ('crm.lead', 'Iniciativa/Oportunidad'),
+        'date': fields.datetime('Fecha'),
+    }
+
+    def _get_default_state(self, cr, uid, context=None):
+        if context and context.get('default_state'):
+            return context.get('default_state')
+        return 'open'
+
+    _defaults = {
+        'date': fields.datetime.now,
+		'date_action_next': fields.datetime.now,
+        'priority': '1',
+        'state':  _get_default_state,
+        'user_id': lambda self, cr, uid, ctx: uid,
+        'active': 1
+    }
+
+    def on_change_partner_id(self, cr, uid, ids, partner_id, context=None):
+        values = {}
+        if partner_id:
+            partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
+            values = {
+                'partner_phone': partner.phone,
+                'partner_mobile': partner.mobile,
+            }
+        return {'value': values}
+
+    def write(self, cr, uid, ids, values, context=None):
+        """ Override to add case management: open/close dates """
+        if values.get('state'):
+            if values.get('state') == 'done':
+                values['date_closed'] = fields.datetime.now()
+            elif values.get('state') == 'open':
+                values['date_open'] = fields.datetime.now()
+        return super(crm_mensaje, self).write(cr, uid, ids, values, context=context)
+
+
+
+    def _call_create_partner(self, cr, uid, mensaje, context=None):
+        partner = self.pool.get('res.partner')
+        partner_id = partner.create(cr, uid, {
+                    'name': mensaje.name,
+                    'user_id': mensaje.user_id.id,
+                    'comment': mensaje.description,
+                    'address': []
+        })
+        return partner_id
+
+
+    def _call_set_partner(self, cr, uid, ids, partner_id, context=None):
+        write_res = self.write(cr, uid, ids, {'partner_id' : partner_id}, context=context)
+        self._call_set_partner_send_note(cr, uid, ids, context)
+        return write_res
+
+    def _call_create_partner_address(self, cr, uid, mensaje, partner_id, context=None):
+        address = self.pool.get('res.partner')
+        return address.create(cr, uid, {
+                    'parent_id': partner_id,
+                    'name': mensaje.name,
+                    'phone': mensaje.partner_phone,})
+
+
+class res_partner(osv.osv):
+    _inherit = 'res.partner'
+    def _mensaje_count(self, cr, uid, ids, field_name, arg, context=None):
+        Claim_mensaje = self.pool['crm.mensaje']
+        return {
+            partner_id: Claim_mensaje.search_count(cr,uid, [('partner_id', '=', partner_id)], context=context)
+            for partner_id in ids
+        }
+
+    _columns = {
+        'mensaje_count': fields.function(_mensaje_count, string='# Contador Mensaje', type='integer'),
+    }
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
crm_mensaje.pyc


+ 43 - 0
crm_mensaje_menu.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+
+        <!-- Claims Menu -->
+        <record model="ir.actions.act_window" id="crm_case_categ_mensaje0">
+            <field name="name">Mensajes</field>
+            <field name="res_model">crm.mensaje</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="view_id" ref="crm_case_mensaje_tree_view"/>
+            <field name="context">{"search_default_user_id":uid}</field>
+            <field name="search_view_id" ref="crm_mensaje.view_crm_case_mensaje_filter"/>
+            <field name="help" type="html">
+                <p class="oe_view_nocontent_create">
+                    Module created for CRM message registration. It records the date, the client, the opportunity and the details of the message.
+                </p>
+            </field>
+        </record>
+
+        <record model="ir.actions.act_window.view" id="action_crm_tag_tree_mensaje0">
+            <field name="sequence" eval="1"/>
+            <field name="view_mode">tree</field>
+            <field name="view_id" ref="crm_case_mensaje_tree_view"/>
+            <field name="act_window_id" ref="crm_case_categ_mensaje0"/>
+        </record>
+
+        <record model="ir.actions.act_window.view" id="action_crm_tag_form_mensaje0">
+            <field name="sequence" eval="2"/>
+            <field name="view_mode">form</field>
+            <field name="view_id" ref="crm_case_mensaje_form_view"/>
+            <field name="act_window_id" ref="crm_case_categ_mensaje0"/>
+        </record>
+
+
+        <menuitem name="Registro Mensaje" id="menu_registro_mensaje"
+            parent="base.menu_base_partner" sequence="2"/>
+
+		<menuitem name="Registro Mensaje" id="id_menu_registro_mensaje"
+            parent="menu_registro_mensaje" action="crm_case_categ_mensaje0" sequence="1"/>
+
+    </data>
+</openerp>

+ 95 - 0
crm_mensaje_view.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+
+    <!-- Mensajes Tree View -->
+    <record model="ir.ui.view" id="crm_case_mensaje_tree_view">
+        <field name="name">CRM - Mensaje Tree</field>
+        <field name="model">crm.mensaje</field>
+        <field name="arch" type="xml">
+            <tree colors="gray:state in ('cancel','done');blue:state in ('pending',)" string="Mensajes">
+                <field name="date"/>
+                <field name="name"/>
+                <field name="partner_id"/>
+				        <field name="partner_mobile"/>
+                <field name="user_id"/>
+				        <field name="date_action_next"/>
+                <field name="date_closed" invisible="1"/>
+                <field name="create_date" invisible="1"/>
+                <field name="opportunity_id"/>
+                <field name="state"/>
+            </tree>
+        </field>
+    </record>
+
+
+
+    <!-- Mensajes Form View -->
+    <record model="ir.ui.view" id="crm_case_mensaje_form_view">
+        <field name="name">CRM - Mensajes Formulario</field>
+        <field name="model">crm.mensaje</field>
+        <field name="arch" type="xml">
+            <form string="Mensajes">
+            <!--   <header>
+                   <button name="button_attachment" string="Attachment"
+                     type="object" icon="gtk-go-forward" colspan='1' />
+                </header> -->
+
+                <header>
+                    <field name="state" nolabel="1" widget="statusbar" clickable="True"/>
+                </header>
+                <sheet string="Mensajes">
+
+                    <div class="oe_title">
+                        <div class="oe_edit_only">
+                            <label for="name"/>
+                        </div>
+                        <h1><field name="name" required="1"/></h1>
+                        <div class="oe_edit_only">
+                            <label for="partner_mobile" string="Celular Nro"/>
+                        </div>
+                        <h2><field name="partner_mobile"/></h2>
+                    </div>
+
+                    <group col="4">
+                        <field name="partner_id" on_change="on_change_partner_id(partner_id)"/>
+                        <field name="date"/>
+                        <field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager']}"/>
+                        <field name="opportunity_id"/>
+                        <field name="priority" widget="priority"/>
+                    </group>
+                    <field name="description" placeholder="Description..."/>
+                </sheet>
+            </form>
+        </field>
+    </record>
+
+    <!-- Llamada Busqueda View  -->
+    <record id="view_crm_case_mensaje_filter" model="ir.ui.view">
+        <field name="name">CRM - Buscador de mensaje</field>
+        <field name="model">crm.mensaje</field>
+        <field name="arch" type="xml">
+            <search string="Buscador Mensajes">
+                <field name="opportunity_id" string="Oportunidad"/>
+                <field name="name" string="Mensajes"/>
+                <field name="date"/>
+                <field name="state"/>
+                <filter string="Mis mensajes" domain="[('user_id', '=', uid)]"/>
+                <filter string="No asignados" domain="[('user_id','=',False)]"/>
+                <separator/>
+                <filter string="Para hacer" name="current" domain="[('state','in',('open','pending'))]"/>
+                <separator/>
+                <field name="partner_id" operator="child_of"/>
+                <field name="user_id"/>
+                <group expand="0" string="Agrupado por">
+                    <filter string="Cliente" domain="[]" context="{'group_by':'partner_id'}"/>
+                    <filter string="Responsable" domain="[]" context="{'group_by':'user_id'}"/>
+                    <filter string="Creacion" help="Creation Date" domain="[]" context="{'group_by':'create_date'}"/>
+                    <filter string="Mes" domain="[]" context="{'group_by':'date'}" help="Dias de Mensajes por Mes"/>
+                </group>
+            </search>
+        </field>
+    </record>
+
+    </data>
+</openerp>

+ 86 - 0
informe_crm_mensaje.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+        <report
+            id="report_crm_mensaje"
+            string="Listado de Mensajes de Clientes"
+            model="crm.mensaje"
+            report_type="qweb-pdf"
+            file="crm_mensaje.report_mensaje"
+            name="crm_mensaje.report_mensaje"
+        />
+  <template id="report_mensaje">
+    <t t-call="report.html_container">
+          <t t-call="report.external_layout">
+            <div class="page">
+				<style type="text/css">
+						.crm_tcab{
+                            font-size: 3mm;
+                            font-family: Arial, Helvetica, sans-serif;
+                        }
+						
+                        .crmc_tbody{
+                            font-size: 2.8mm;
+                            font-family: Arial, Helvetica, sans-serif;
+                        }
+                        .taxtotal{
+                            font-size: 2.8mm;
+                        }
+						.total{
+                            font-size: 2.8mm;
+                        }
+						.untotal{
+                            font-size: 2.8mm;
+                        }
+						.logo1{
+                            width: 100%;
+                            top: 1.5cm;
+                        }
+                        
+				</style>
+			   <h4 class="text-center">Listado de Mensajes de Clientes</h4> 
+               <div class="logo1"> </div>
+			   <table class="table table-bordered">
+				<thead class="crm_tcab">
+					<tr class="active">
+                        <th class="text-left">Fecha y Hora</th>
+                        <th class="text-left">Cliente</th>
+                        <th class="text-left">Movil1</th>
+						<th class="text-left">Movil2</th>
+                        <th class="text-left">Descripcion</th>
+						<th class="text-left">Prox.Accion</th>
+                        <th class="text-left">Estado</th>
+                    </tr>
+                </thead>
+               <t t-foreach="docs" t-as="o">
+                <tbody class="crmc_tbody">
+                        <td class="text-left">
+                            <span t-field="o.create_date"/>
+                        </td>
+                        <td class="text-left">
+                            <span t-field="o.partner_id"/>
+                        </td>
+                        <td class="text-left">
+                            <span t-field="o.partner_phone"/>
+                        </td>
+						<td class="text-left">
+                            <span t-field="o.partner_mobile"/>
+                        </td>
+						<td class="text-left">
+                            <span t-field="o.description"/>
+                        </td>
+						<td class="text-left">
+                            <span t-field="o.action_next"/>
+                        </td>
+                        <td class="text-left">
+                            <span t-field="o.state"/> 
+                        </td>                   
+                </tbody>
+               </t>
+             </table>
+            </div>
+          </t>
+    </t>
+  </template>
+</data>
+</openerp>

+ 107 - 0
res_partner.py

@@ -0,0 +1,107 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import fields,osv
+
+class res_partner(osv.osv):
+    """ Inherits partner and adds CRM information in the partner form """
+    _inherit = 'res.partner'
+
+    def _opportunity_meeting_phonecall_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,{'opportunity_count': 0, 'meeting_count': 0}), ids))
+        # the user may not have access rights for opportunities or meetings
+        try:
+            for partner in self.browse(cr, uid, ids, context):
+                if partner.is_company:
+                    operator = 'child_of'
+                else:
+                    operator = '='
+                opp_ids = self.pool['crm.lead'].search(cr, uid, [('partner_id', operator, partner.id), ('type', '=', 'opportunity'), ('probability', '<', '100')], context=context)
+                res[partner.id] = {
+                    'opportunity_count': len(opp_ids),
+                    'meeting_count': len(partner.meeting_ids),
+                }
+        except:
+            pass
+        return res
+
+    def _phonecall_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = {}
+        for partner in self.browse(cr, uid, ids, context):
+            res[partner.id] = len(partner.phonecall_ids)
+        return res
+
+    _columns = {
+        'section_id': fields.many2one('crm.case.section', 'Sales Team'),
+        'opportunity_ids': fields.one2many('crm.lead', 'partner_id',\
+            'Leads and Opportunities', domain=[('probability', 'not in', ['0', '100'])]),
+        'meeting_ids': fields.many2many('calendar.event', 'calendar_event_res_partner_rel','res_partner_id', 'calendar_event_id',
+            'Meetings'),
+        'phonecall_ids': fields.one2many('crm.phonecall', 'partner_id',\
+            'Phonecalls'),
+        'opportunity_count': fields.function(_opportunity_meeting_phonecall_count, string="Opportunity", type='integer', multi='opp_meet'),
+        'meeting_count': fields.function(_opportunity_meeting_phonecall_count, string="# Meetings", type='integer', multi='opp_meet'),
+        'phonecall_count': fields.function(_phonecall_count, string="Phonecalls", type="integer"),
+    }
+
+    def redirect_partner_form(self, cr, uid, partner_id, context=None):
+        search_view = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'view_res_partner_filter')
+        value = {
+            'domain': "[]",
+            'view_type': 'form',
+            'view_mode': 'form,tree',
+            'res_model': 'res.partner',
+            'res_id': int(partner_id),
+            'view_id': False,
+            'context': context,
+            'type': 'ir.actions.act_window',
+            'search_view_id': search_view and search_view[1] or False
+        }
+        return value
+
+    def make_opportunity(self, cr, uid, ids, opportunity_summary, planned_revenue=0.0, probability=0.0, partner_id=None, context=None):
+        categ_obj = self.pool.get('crm.case.categ')
+        categ_ids = categ_obj.search(cr, uid, [('object_id.model','=','crm.lead')])
+        lead_obj = self.pool.get('crm.lead')
+        opportunity_ids = {}
+        for partner in self.browse(cr, uid, ids, context=context):
+            if not partner_id:
+                partner_id = partner.id
+            opportunity_id = lead_obj.create(cr, uid, {
+                'name' : opportunity_summary,
+                'planned_revenue' : planned_revenue,
+                'probability' : probability,
+                'partner_id' : partner_id,
+                'categ_ids' : categ_ids and categ_ids[0:1] or [],
+                'type': 'opportunity'
+            }, context=context)
+            opportunity_ids[partner_id] = opportunity_id
+        return opportunity_ids
+
+    def schedule_meeting(self, cr, uid, ids, context=None):
+        partner_ids = list(ids)
+        partner_ids.append(self.pool.get('res.users').browse(cr, uid, uid).partner_id.id)
+        res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, 'calendar', 'action_calendar_event', context)
+        res['context'] = {
+            'search_default_partner_ids': list(ids),
+            'default_partner_ids': partner_ids,
+        }
+        return res

+ 45 - 0
res_partner_view.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+		 <record id="crm_case_categ_mensaje1" model="ir.actions.act_window">
+            <field name="name">Mensajes</field>
+            <field name="res_model">crm.mensaje</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="context">{'search_default_partner_id': active_id}</field>
+            <field name="help" type="html">
+              <p class="oe_view_nocontent_create">
+                Click to create a quotation or sales order for this customer.
+              </p><p>
+                Odoo will help you efficiently handle the complete sale flow:
+                quotation, sales order, delivery, invoicing and
+                payment.
+              </p><p>
+                The social feature helps you organize discussions on each sales
+                order, and allow your customer to keep track of the evolution
+                of the sales order.
+              </p>
+            </field>
+        </record>
+
+		<!--  Partners inherited form -->
+        <record id="view_mensaje_partner_info_form" model="ir.ui.view">
+            <field name="name">res.partner.mensaje.buttons</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" type="action" name="%(crm_mensaje.crm_case_categ_mensaje1)d"
+						             attrs="{'invisible': [('customer', '=', False)]}"
+						             context="{'search_default_partner_id': active_id, 'default_partner_id': active_id}"
+						             icon="fa-pencil-square-o">
+						             <field  string="Mensajes" name="mensaje_count" widget="statinfo"/>
+                    </button>
+                </xpath>
+            </field>
+       </record>
+
+    </data>
+</openerp>

BIN
static/description/icon.png