From e06d92397ba302c665ee9fc4e5c298282624178e Mon Sep 17 00:00:00 2001 From: Ludovic CHEVALIER Date: Mon, 25 May 2020 17:45:57 +0200 Subject: [PATCH] [PYTHON] ~concatenate partner mobile and phone number on event registration --- __openerp__.py | 8 ++++++-- lhc.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/__openerp__.py b/__openerp__.py index 9576907..c0aee7c 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -28,8 +28,12 @@ '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 --- 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: -- 2.20.1