Rodney Enciso Arias преди 8 години
ревизия
0b08ce04bf

+ 25 - 0
__init__.py

@@ -0,0 +1,25 @@
+# -*- 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 partner_social_fields
+import crm_lead_social_fields
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

BIN
__init__.pyc


+ 36 - 0
__openerp__.py

@@ -0,0 +1,36 @@
+# -*- 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': 'Partners Go Social!',
+    'version': '2.0',
+    'category': 'Tools',
+    'description': """This module allows to add social fields to the partners addresses.""",
+    'author': 'Sistemas ADHOC/Rodney Enciso Arias',
+    'website': 'http://www.sistemasadhoc.com.ar/',
+    'depends': ['base','crm'],
+    'data': ['partner_social_fields_view.xml',
+             'crm_lead_social_fields_view.xml',
+            ],
+    'installable': True,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 125 - 0
crm_lead_social_fields.py

@@ -0,0 +1,125 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_features for OpenERP                                               #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.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 openerp import models, fields, tools
+
+class crm_lead(models.Model):
+    _name = 'crm.lead'
+    _inherit = 'crm.lead'
+
+    #Campos
+    facebook = fields.Char('Facebook', size=64, required=False, readonly=False)
+    twitter = fields.Char('Twitter', size=64, required=False, readonly=False)
+    skype = fields.Char('Skype', size=64, required=False, readonly=False)
+    msn = fields.Char('MSN', size=64, required=False, readonly=False)
+    instagram = fields.Char('Instagram', size=64, required=False, readonly=False)
+    whatsapp = fields.Boolean('Whatsapp',help='Marque está opción si el cliente tiene Whatsapp')
+    primer_contacto = fields.Many2one('res.partner.primer.contacto','Por cual medio se enteró de la empresa?',help='Medio por cual supo acerca de la empresa')
+
+    def goto_facebook(self, cr, uid, ids, context=None):
+        partner_obj = self.pool.get('res.partner')
+        partner = partner_obj.browse(cr, uid, ids, context=context)[0]
+        if partner.facebook:
+            good_starting_urls = ['https://facebook.com/', 'https://www.facebook.com/', \
+                                  'http://facebook.com/', 'http://www.facebook.com/']
+            non_protocol_starting_urls = ['facebook.com/', 'www.facebook.com/']
+
+            if any(map(lambda x: partner.facebook.startswith(x), good_starting_urls)):
+                url = partner.facebook
+            elif any(map(lambda x: partner.facebook.startswith(x), non_protocol_starting_urls)):
+                url = 'https://' + partner.facebook
+            else:
+                url = 'https://www.facebook.com/' + partner.facebook
+
+            return {'type': 'ir.actions.act_url', 'url': url, 'target': 'new'}
+
+    def goto_twitter(self, cr, uid, ids, context=None):
+        partner_obj = self.pool.get('res.partner')
+        partner = partner_obj.browse(cr, uid, ids, context=context)[0]
+
+        if partner.twitter:
+            good_starting_urls = ['https://twitter.com/', 'https://www.twitter.com/', \
+                                  'http://twitter.com/', 'http://www.twitter.com/']
+            non_protocol_starting_urls = ['twitter.com/', 'www.twitter.com/']
+
+            if any(map(lambda x: partner.twitter.startswith(x), good_starting_urls)):
+                url = partner.twitter
+            elif any(map(lambda x: partner.twitter.startswith(x), non_protocol_starting_urls)):
+                url = 'https://' + partner.twitter
+            else:
+                url = 'https://www.twitter.com/' + partner.twitter
+
+            return {'type': 'ir.actions.act_url', 'url': url, 'target': 'new'}
+
+    def goto_instagram(self, cr, uid, ids, context=None):
+        partner_obj = self.pool.get('res.partner')
+        partner = partner_obj.browse(cr, uid, ids, context=context)[0]
+
+        if partner.instagram:
+            good_starting_urls = ['https://instagram.com/', 'https://www.instagram.com/', \
+                                  'http://instagram.com/', 'http://www.instagram.com/']
+            non_protocol_starting_urls = ['instagram.com/', 'www.instagram.com/']
+
+            if any(map(lambda x: partner.instagram.startswith(x), good_starting_urls)):
+                url = partner.instagram
+            elif any(map(lambda x: partner.instagram.startswith(x), non_protocol_starting_urls)):
+                url = 'https://' + partner.instagram
+            else:
+                url = 'https://www.instagram.com/' + partner.instagram
+
+            return {'type': 'ir.actions.act_url', 'url': url, 'target': 'new'}
+
+    def _lead_create_contact(self, cr, uid, lead, name, is_company, parent_id=False, context=None):
+        partner = self.pool.get('res.partner')
+        vals = {'name': name,
+            'user_id': lead.user_id.id,
+            'comment': lead.description,
+            'section_id': lead.section_id.id or False,
+            'parent_id': parent_id,
+            'phone': lead.phone,
+            'mobile': lead.mobile,
+            'email': tools.email_split(lead.email_from) and tools.email_split(lead.email_from)[0] or False,
+            'fax': lead.fax,
+            'title': lead.title and lead.title.id or False,
+            'function': lead.function,
+            'street': lead.street,
+            'street2': lead.street2,
+            'zip': lead.zip,
+            'city': lead.city,
+            'country_id': lead.country_id and lead.country_id.id or False,
+            'state_id': lead.state_id and lead.state_id.id or False,
+            'is_company': is_company,
+            'type': 'contact',
+            'facebook':lead.facebook,
+            'twitter':lead.twitter,
+            'instagram':lead.instagram,
+            'skype':lead.skype,
+            'msn':lead.msn,
+            'whatsapp':lead.whatsapp,
+            'primer_contacto': lead.primer_contacto and lead.primer_contacto.id or False
+        }
+        partner = partner.create(cr, uid, vals, context=context)
+        return partner
+
+crm_lead()

BIN
crm_lead_social_fields.pyc


+ 39 - 0
crm_lead_social_fields_view.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  product_features for OpenERP
+  Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).
+    Authors, Mathieu Lemercier, mathieu@netandco.net, Franck Bret, franck@netandco.net
+  Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>
+  The licence is in the file __openerp__.py
+-->
+<openerp>
+    <data>
+        <record id="crm_lead_form_extra_social" model="ir.ui.view">
+            <field name="name">crm.lead.form.extra.social</field>
+            <field name="model">crm.lead</field>
+            <field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
+            <field name="arch" type="xml">
+                <field name="mobile" position="after">
+                    <field name="whatsapp"/>
+                </field>
+                <page string="Internal Notes" position="after">
+                    <page name="Social" string="Información Social">
+                        <group col="3">     
+                            <field name="facebook"/>
+                            <button name="goto_facebook" string="Ir" type="object"/>
+                            <field name="twitter"/>
+                            <button name="goto_twitter" string="Ir" type="object"/>
+                        </group>
+                        <group>
+                            <field name="skype"/>
+                        </group>
+                       
+                        <group col="2">
+                            <field name="primer_contacto" options="{'no_create':True,'no_open':True}"/>
+                        </group> 
+                    </page>
+                </page> 
+            </field>
+        </record>
+    </data>
+</openerp>

+ 38 - 0
i18n/en.po

@@ -0,0 +1,38 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * partner_social_fields
+# 
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: odoo-addons (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-09-09 23:57+0000\n"
+"PO-Revision-Date: 2015-09-01 18:00+0000\n"
+"Last-Translator: Juan Jose Scarafia <scarafia.juanjose@gmail.com>\n"
+"Language-Team: English (http://www.transifex.com/adhoc/ingadhoc-odoo-addons-8-0/language/en/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: en\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: partner_social_fields
+#: field:res.partner,facebook:0
+msgid "Facebook"
+msgstr "Facebook"
+
+#. module: partner_social_fields
+#: model:ir.model,name:partner_social_fields.model_res_partner
+msgid "Partner"
+msgstr "Partner"
+
+#. module: partner_social_fields
+#: field:res.partner,skype:0
+msgid "Skype"
+msgstr "Skype"
+
+#. module: partner_social_fields
+#: field:res.partner,twitter:0
+msgid "Twitter"
+msgstr "Twitter"

+ 80 - 0
partner_social_fields.py

@@ -0,0 +1,80 @@
+# -*- 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 osv, fields
+
+class res_partner(osv.osv):
+    '''
+    Add social media to res.partner
+    '''
+    _name = 'res.partner'
+    _inherit = 'res.partner'
+    _description = 'Add social media to Partner'
+
+    _columns = {        
+        'facebook':fields.char('Facebook', size=64, required=False, readonly=False),
+        'twitter':fields.char('Twitter', size=64, required=False, readonly=False),
+        'skype':fields.char('Skype', size=64, required=False, readonly=False),
+        'msn':fields.char('MSN', size=64, required=False, readonly=False),
+        'whatsapp':fields.boolean('Whatsapp',help='Marque está opción si el cliente tiene Whatsapp'),
+        'primer_contacto':fields.many2one('res.partner.primer.contacto','Por cual medio se enteró de la empresa?',help='Medio por cual supo acerca de la empresa'),
+    }
+    
+    def goto_facebook(self, cr, uid, ids, context=None):
+        partner_obj = self.pool.get('res.partner')
+        partner = partner_obj.browse(cr, uid, ids, context=context)[0]
+        if partner.facebook:
+            good_starting_urls = ['https://facebook.com/', 'https://www.facebook.com/', \
+                                  'http://facebook.com/', 'http://www.facebook.com/']
+            non_protocol_starting_urls = ['facebook.com/', 'www.facebook.com/']
+            
+            if any(map(lambda x: partner.facebook.startswith(x), good_starting_urls)):
+                url = partner.facebook
+            elif any(map(lambda x: partner.facebook.startswith(x), non_protocol_starting_urls)):
+                url = 'https://' + partner.facebook
+            else:
+                url = 'https://www.facebook.com/' + partner.facebook
+            
+            return {'type': 'ir.actions.act_url', 'url': url, 'target': 'new'}
+    
+    def goto_twitter(self, cr, uid, ids, context=None):
+        partner_obj = self.pool.get('res.partner')
+        partner = partner_obj.browse(cr, uid, ids, context=context)[0]
+        
+        if partner.twitter:
+            good_starting_urls = ['https://twitter.com/', 'https://www.twitter.com/', \
+                                  'http://twitter.com/', 'http://www.twitter.com/']
+            non_protocol_starting_urls = ['twitter.com/', 'www.twitter.com/']
+            
+            if any(map(lambda x: partner.twitter.startswith(x), good_starting_urls)):
+                url = partner.twitter
+            elif any(map(lambda x: partner.twitter.startswith(x), non_protocol_starting_urls)):
+                url = 'https://' + partner.twitter
+            else:
+                url = 'https://www.twitter.com/' + partner.twitter
+            
+            return {'type': 'ir.actions.act_url', 'url': url, 'target': 'new'}
+    
+class res_partner_primer_contacto(osv.osv):
+    _name = 'res.partner.primer.contacto'
+    _columns = {
+        'name':fields.char('Forma de Contacto', size=64, required=False),
+    }

BIN
partner_social_fields.pyc


+ 65 - 0
partner_social_fields_view.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+
+        <record id="view_partner_social_form1" model="ir.ui.view">
+            <field name="name">res.partner.social.inherit1</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="base.view_partner_form"/>
+            <field name="arch" type="xml">
+                <field name="mobile" position="after">
+                    <field name="whatsapp"/>
+                </field>
+                 <page string="Internal Notes" position="after">
+                    <page name="Social" string="Información Social">
+                        <group col="3">     
+                            <field name="facebook"/>
+                            <button name="goto_facebook" string="Ir" type="object"/>
+                            <field name="twitter"/>
+                            <button name="goto_twitter" string="Ir" type="object"/>
+                        </group>
+                        <group>
+                            <field name="skype"/>
+                        </group>
+                       
+                        <group col="2">
+                            <field name="primer_contacto" options="{'no_create':True,'no_open':True}"/>
+                        </group> 
+                    </page>
+                </page> 
+            </field>
+        </record>
+
+        <record model="ir.ui.view" id="view_partner_primer_contacto_form">
+            <field name="name">res.partner.primer.contacto.form</field>
+            <field name="model">res.partner.primer.contacto</field>
+            <field name="arch" type="xml">
+                <form string="Primer Contacto" version="7.0">
+                    <group>
+                        <field name="name"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <record model="ir.ui.view" id="view_partner_primer_contacto_tree">
+            <field name="name">res.partner.primer.contacto.tree</field>
+            <field name="model">res.partner.primer.contacto</field>
+            <field name="arch" type="xml">
+                <tree string="partner.primer.contacto">
+                    <field name="name"/>                   
+                </tree>
+            </field>
+        </record>
+
+        <record model="ir.actions.act_window" id="action_partner_primer_contacto">
+            <field name="name">Primer Contacto</field>
+            <field name="res_model">res.partner.primer.contacto</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+        <!--<menuitem name="Primer Contacto" id="menu_partner_primer_contacto" action="action_partner_primer_contacto" parent="base.menu_base_config" sequence="26"/>-->
+        <menuitem name="Primer Contacto" id="menu_partner_primer_contacto" action="action_partner_primer_contacto" parent="crm.root_menu" sequence="20"/>
+    </data>
+</openerp>

+ 2 - 0
security/ir.model.access.csv

@@ -0,0 +1,2 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_partner_primer_contacto","res.partner.primer.contacto","model_res_partner_primer_contacto","base.group_partner_manager",1,1,1,1

BIN
static/description/icon.png