Odoo Help

Welcome!

This community 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.

0

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

By
divya
on 8/28/14, 2:37 AM 1,247 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
5

Openies Services

--Openies Services--
925
| 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.

 

-1

Odoo

--Odoo --
1328
| 5 2 5
kerala, India
--Odoo --

Working as a Odoo Functional and Technical Expert

Odoo
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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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