Browse Source

commit inicial

Rodney Enciso Arias 8 years ago
commit
0cc4a2f064
4 changed files with 147 additions and 0 deletions
  1. 23 0
      __init__.py
  2. 35 0
      __openerp__.py
  3. 67 0
      partner_social_extends.py
  4. 22 0
      partner_social_extends_view.xml

+ 23 - 0
__init__.py

@@ -0,0 +1,23 @@
+# -*- 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_extends
+

+ 35 - 0
__openerp__.py

@@ -0,0 +1,35 @@
+# -*- 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': 'Extends Partner Social Fields',
+    'version': '1.0',
+    'category': 'Tools',
+    'description': """This module allows to add social fields to the partners addresses.""",
+    'author': 'Rodney Enciso Arias',
+    'website': 'http://www.eiru.com.py/',
+    'depends': ['base','crm','partner_social_fields'],
+    'data': ['partner_social_extends_view.xml',
+            ],
+    'installable': True,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 67 - 0
partner_social_extends.py

@@ -0,0 +1,67 @@
+# -*- 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):
+    
+    _name = 'res.partner'
+    _inherit = 'res.partner'
+
+    _columns = {        
+        'instagram':fields.char('Instagram', size=64),
+        'linkedin':fields.char('LinkedIn', size=64),
+    }
+
+    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 goto_linkedin(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.linkedin:
+            good_starting_urls = ['https://linkedin.com/', 'https://www.linkedin.com/', \
+                                  'http://linkedin.com/', 'http://www.linkedin.com/']
+            non_protocol_starting_urls = ['linkedin.com/', 'www.linkedin.com/']
+            
+            if any(map(lambda x: partner.linkedin.startswith(x), good_starting_urls)):
+                url = partner.linkedin
+            elif any(map(lambda x: partner.linkedin.startswith(x), non_protocol_starting_urls)):
+                url = 'https://' + partner.linkedin
+            else:
+                url = 'https://www.linkedin.com/' + partner.linkedin
+            
+            return {'type': 'ir.actions.act_url', 'url': url, 'target': 'new'}

+ 22 - 0
partner_social_extends_view.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+        <record id="view_partner_social_extends_form" model="ir.ui.view">
+            <field name="name">res.partner.social.extends</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="partner_social_fields.view_partner_social_form1"/>
+            <field name="arch" type="xml">
+                
+                <field name="skype" position="before">
+                    <group col="3" colspan="2">
+                        <field name="instagram"/>
+                        <button name="goto_instagram" string="Ir" type="object"/>
+                        <field name="linkedin"/>
+                        <button name="goto_linkedin" string="Ir" type="object"/>
+                    </group> 
+                </field>    
+               
+            </field>
+        </record>
+    </data>
+</openerp>