Odoo Help


How replace a field in openerp by adding additional data to that field ??

on 8/28/14, 2:37 AM 1,808 views

For example I have two fields Name =divya and Email=kalluru@gmail.com after saving Email = divya<kalluru@gmail.com>

 <field name="name"/>

<field name="email"/>

how to replace email by  splitting  it in to this formate can any please provide code for it.


Divya, you should create either a functonal field, or run an onchange method to combine them.

Serpent Consulting Services Pvt. Ltd.
on 9/21/14, 11:54 AM

Openies Services

--Openies Services--
| 2 2 4
Vadodara, India
--Openies Services--

We provide Odoo Services.

Contact us on : contact@openies.com

Openies Services
On 9/21/14, 12:41 PM

It can be easily achieved by overriding create and  write functions. for Example,

def create(self, cr, uid, vals, context=None):
    if vals.get('name') and vals.get('email'):
        vals.update({'email': vals.get('name') + ' <' + vals.get('email') + '>'})
    return super(class_name, self).create(cr, uid, vals, context)

and write method

def write(self, cr, uid, ids, vals, context=None):
    for rec in self.browse(cr, uid, ids, context):
        if vals.get('name') or vals.get('email'):
            vals.update({'email': vals.get('name') or rec.name + ' <' + vals.get('email') or rec.email + '>'})
    return super(class_name, self).write(cr, uid, ids, vals, context)

Hope this helps.




--Odoo --

| 5 2 5
--Odoo --

Working in Odoo TEchnologies

On 8/28/14, 3:21 AM

Use Python Regular expressions and String Split Method ,

Emails Example

Suppose you want to find the email address inside the string 'xyz alice-b@google.com purple monkey'. We'll use this as a running example to demonstrate more regular expression features. Here's an attempt using the pattern r'\w+@\w+':

  str = 'purple alice-b@google.com monkey dishwasher'   match = re.search(r'\w+@\w+', str)   if match:     print match.group()  ## 'b@google'

The search does not get the whole email address in this case because the \w does not match the '-' or '.' in the address. We'll fix this using the regular expression features below.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 8/28/14, 2:37 AM
Seen: 1808 times
Last updated: 3/16/15, 8:10 AM