-
+
+
diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py
index bef82825723..d94a7092b45 100644
--- a/openerp/addons/base/res/res_partner.py
+++ b/openerp/addons/base/res/res_partner.py
@@ -19,9 +19,10 @@
#
##############################################################################
-import os
import math
+import os
from osv import osv, fields
+import re
import tools
from tools.translate import _
import logging
@@ -304,6 +305,37 @@ class res_partner(osv.osv):
res.append((record.id, name))
return res
+ def name_create(self, cr, uid, name, context=None):
+ """ Override of orm's name_create method for partners. The purpose is
+ to handle some basic formats to create partners using the
+ name_create.
+ Supported syntax:
+ - 'raoul@grosbedon.fr': create a partner with name raoul@grosbedon.fr
+ and sets its email to raoul@grosbedon.fr
+ - 'Raoul Grosbedon
': create a partner with name
+ Raoul Grosbedon, and set its email to raoul@grosbedon.fr
+ - anything else: fall back on the default name_create
+ Regex :
+ - ([a-zA-Z0-9._%-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9._]{1,8}): raoul@grosbedon.fr
+ - ([\w\s.\\-]+)[\<]([a-zA-Z0-9._%-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9._]{1,8})[\>]:
+ Raoul Grosbedon, raoul@grosbedon.fr
+ """
+ contact_regex = re.compile('([\w\s.\\-]+)[\<]([a-zA-Z0-9._%-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9._]{1,8})[\>]')
+ email_regex = re.compile('([a-zA-Z0-9._%-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9._]{1,8})')
+ contact_regex_res = contact_regex.findall(name)
+ email_regex_res = email_regex.findall(name)
+ if contact_regex_res:
+ name = contact_regex_res[0][0].rstrip(' ') # remove extra spaces on the right
+ email = contact_regex_res[0][1]
+ rec_id = self.create(cr, uid, {self._rec_name: name, 'email': email}, context);
+ return self.name_get(cr, uid, [rec_id], context)[0]
+ elif email_regex:
+ email = '%s' % (email_regex_res[0])
+ rec_id = self.create(cr, uid, {self._rec_name: email, 'email': email}, context);
+ return self.name_get(cr, uid, [rec_id], context)[0]
+ else:
+ return super(res_partner, self).create(cr, uid, name, context)
+
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
if not args:
args = []
diff --git a/openerp/addons/base/res/res_partner_view.xml b/openerp/addons/base/res/res_partner_view.xml
index 8dfe058e563..ebc4944fc7d 100644
--- a/openerp/addons/base/res/res_partner_view.xml
+++ b/openerp/addons/base/res/res_partner_view.xml
@@ -1,16 +1,18 @@
-
+
+
+
+
-
+
res.partner.title.tree
res.partner.title
@@ -69,11 +71,8 @@
-
+
+
res.partner.tree
res.partner
@@ -103,7 +102,7 @@
-
+
( )
@@ -118,7 +117,7 @@
,
+ on_change="onchange_address(use_parent_address, parent_id)"/>,
-
+
@@ -213,18 +212,24 @@
+
+
+
+
+
+
-
-
-
+
+
+
@@ -241,7 +246,7 @@
-
@@ -249,7 +254,7 @@
-
+
@@ -429,11 +434,8 @@
form
-
+
+
Partner Categories
res.partner.category
@@ -512,4 +514,3 @@
-
diff --git a/openerp/addons/base/res/res_users_view.xml b/openerp/addons/base/res/res_users_view.xml
index 4f8fb9f94fd..546c1c063b8 100644
--- a/openerp/addons/base/res/res_users_view.xml
+++ b/openerp/addons/base/res/res_users_view.xml
@@ -58,7 +58,7 @@
-
+
@@ -199,7 +199,7 @@
()
-
+
diff --git a/openerp/modules/db.py b/openerp/modules/db.py
index 2449efc7fcd..7490631a3b9 100644
--- a/openerp/modules/db.py
+++ b/openerp/modules/db.py
@@ -77,8 +77,8 @@ def initialize(cr):
cr.execute('INSERT INTO ir_module_module \
(author, website, name, shortdesc, description, \
- category_id, auto_install, state, certificate, web, license, application, icon, sequence) \
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id', (
+ category_id, auto_install, state, certificate, web, license, application, icon, sequence, summary) \
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id', (
info['author'],
info['website'], i, info['name'],
info['description'], category_id,
@@ -86,7 +86,7 @@ def initialize(cr):
info['web'],
info['license'],
info['application'], info['icon'],
- info['sequence']))
+ info['sequence'], info['summary']))
id = cr.fetchone()[0]
cr.execute('INSERT INTO ir_model_data \
(name,model,module, res_id, noupdate) VALUES (%s,%s,%s,%s,%s)', (
diff --git a/openerp/modules/module.py b/openerp/modules/module.py
index 265a23190e5..b1d4de31bce 100644
--- a/openerp/modules/module.py
+++ b/openerp/modules/module.py
@@ -341,6 +341,7 @@ def load_information_from_description_file(module):
'web': False,
'website': '',
'sequence': 100,
+ 'summary': '',
}
info.update(itertools.izip(
'depends data demo test init_xml update_xml demo_xml'.split(),
diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py
index 2a6d0d6e3eb..b7f47fe6549 100644
--- a/openerp/osv/fields.py
+++ b/openerp/osv/fields.py
@@ -49,7 +49,7 @@ import simplejson
_logger = logging.getLogger(__name__)
def _symbol_set(symb):
- if symb == None or symb == False:
+ if symb is None or symb == False:
return None
elif isinstance(symb, unicode):
return symb.encode('utf-8')
@@ -181,8 +181,8 @@ class reference(_column):
class char(_column):
_type = 'char'
- def __init__(self, string, size, **args):
- _column.__init__(self, string=string, size=size, **args)
+ def __init__(self, string="unknown", size=None, **args):
+ _column.__init__(self, string=string, size=size or None, **args)
self._symbol_set = (self._symbol_c, self._symbol_set_char)
# takes a string (encoded in utf8) and returns a string (encoded in utf8)
@@ -191,7 +191,7 @@ class char(_column):
# * we need to remove the "symb==False" from the next line BUT
# for now too many things rely on this broken behavior
# * the symb==None test should be common to all data types
- if symb == None or symb == False:
+ if symb is None or symb == False:
return None
# we need to convert the string to a unicode object to be able
diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py
index 78487e7641c..a62561fc95d 100644
--- a/openerp/osv/orm.py
+++ b/openerp/osv/orm.py
@@ -758,7 +758,7 @@ class BaseModel(object):
'model_id': model_id,
'model': self._name,
'name': k,
- 'field_description': f.string.replace("'", " "),
+ 'field_description': f.string,
'ttype': f._type,
'relation': f._obj or '',
'view_load': (f.view_load and 1) or 0,
@@ -767,7 +767,7 @@ class BaseModel(object):
'required': (f.required and 1) or 0,
'selectable': (f.selectable and 1) or 0,
'translate': (f.translate and 1) or 0,
- 'relation_field': (f._type=='one2many' and isinstance(f, fields.one2many)) and f._fields_id or '',
+ 'relation_field': f._fields_id if isinstance(f, fields.one2many) else '',
'serialization_field_id': None,
}
if getattr(f, 'serialization_field', None):