[PYTHON] ~concatenate partner mobile and phone number on event registration
authorLudovic CHEVALIER <ludovic@beurresarrasin.net>
Mon, 25 May 2020 15:45:57 +0000 (17:45 +0200)
committerLudovic CHEVALIER <ludovic@beurresarrasin.net>
Mon, 25 May 2020 15:45:57 +0000 (17:45 +0200)
__openerp__.py
lhc.py

index 9576907..c0aee7c 100644 (file)
     'complexity': "normal",
     'description': """
 
-Module pour les personnalisations de L'Heureux Cyclage
-======================================================
+Custom module for L'Heureux Cyclage
+===================================
+- Customing for professionnal training activities;
+- Event management optimization;
+- Add some partners fields;
+- …
     """,
     'author': 'L\'Heureux Cyclage',
     'website': 'http://www.heureux-cyclage.org',
diff --git a/lhc.py b/lhc.py
index fc2c4dc..2dbc18b 100644 (file)
--- a/lhc.py
+++ b/lhc.py
@@ -125,4 +125,22 @@ class event_registration(orm.Model):
         ),
     }
 
+    def onchange_contact_id(self, cr, uid, ids, contact, partner, context=None):
+        """Concat phone with mobile phone if exist. If mobile exist and not
+        phone, add mobile number"""
+        vals = super(event_registration, self).onchange_contact_id(cr, uid, ids, contact, partner, context)
+        addr_obj = self.pool.get('res.partner')
+        contact_id = addr_obj.browse(cr, uid, contact, context=context)
+        phone = vals['value']['phone']
+        mobile = contact_id.mobile
+        import pdb
+        pdb.set_trace()
+        if mobile:
+            if phone:
+                vals['value']['phone'] = '%s - %s' % (phone, mobile)
+            else:
+                vals['value']['phone'] = mobile
+        return vals
+
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: