diff --git a/partner_firstname/__init__.py b/partner_firstname/__init__.py
new file mode 100644
index 000000000..ec7a9bae4
--- /dev/null
+++ b/partner_firstname/__init__.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi. Copyright Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import partner
+from . import res_user
diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py
new file mode 100644
index 000000000..751dd2735
--- /dev/null
+++ b/partner_firstname/__openerp__.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi. Copyright Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+{
+ 'name': 'Partner first name, last name',
+ 'description': """
+This module splits first name and last name for non company partners
+====================================================================
+
+The field 'name' becomes a stored function field concatenating lastname and
+firstname
+Note: in version 7.0, installing this module invalidates a yaml test in the
+'edi' module
+
+Contributors
+============
+Jonathan Nemry
+Olivier Laurent
+
+""",
+ 'version': '1.2',
+ 'author': 'Camptocamp',
+ 'maintainer': 'Camptocamp, Acsone',
+ 'category': 'Extra Tools',
+ 'website': 'http://www.camptocamp.com, http://www.acsone.eu',
+ 'depends': ['base'],
+ 'data': [
+ 'partner_view.xml',
+ 'res_user_view.xml',
+ ],
+ 'demo': [],
+ 'test': [],
+ 'auto_install': False,
+ 'installable': True,
+ 'images': []
+}
diff --git a/partner_firstname/i18n/de.po b/partner_firstname/i18n/de.po
new file mode 100644
index 000000000..7b5eb2551
--- /dev/null
+++ b/partner_firstname/i18n/de.po
@@ -0,0 +1,52 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * partner_firstname
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-04 10:36+0000\n"
+"PO-Revision-Date: 2013-02-04 10:36+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: partner_firstname
+#: code:addons/partner_firstname/partner.py:81
+#: code:addons/partner_firstname/res_user.py:35
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
+#, python-format
+msgid "%s (copy)"
+msgstr "%s (kopie)"
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_users
+msgid "Users"
+msgstr "Benutzer"
+
+#. module: partner_firstname
+#: field:res.partner,firstname:0
+msgid "Firstname"
+msgstr "Vorname"
+
+#. module: partner_firstname
+#: field:res.partner,lastname:0
+msgid "Lastname"
+msgstr "Name"
+
+#. module: partner_firstname
+#: view:res.partner:0
+msgid "Is a Company?"
+msgstr "Ist ein Unternehmen?"
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_partner
+msgid "Partner"
+msgstr "Partner"
diff --git a/partner_firstname/i18n/en.po b/partner_firstname/i18n/en.po
new file mode 100644
index 000000000..7cccf0a33
--- /dev/null
+++ b/partner_firstname/i18n/en.po
@@ -0,0 +1,52 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * partner_firstname
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-04 10:36+0000\n"
+"PO-Revision-Date: 2013-02-04 10:36+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: partner_firstname
+#: code:addons/partner_firstname/partner.py:81
+#: code:addons/partner_firstname/res_user.py:35
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
+#, python-format
+msgid "%s (copy)"
+msgstr "%s (copy)"
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_users
+msgid "Users"
+msgstr "Users"
+
+#. module: partner_firstname
+#: field:res.partner,firstname:0
+msgid "Firstname"
+msgstr "Firstname"
+
+#. module: partner_firstname
+#: field:res.partner,lastname:0
+msgid "Lastname"
+msgstr "Lastname"
+
+#. module: partner_firstname
+#: view:res.partner:0
+msgid "Is a Company?"
+msgstr "Is a Company?"
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_partner
+msgid "Partner"
+msgstr "Partner"
diff --git a/partner_firstname/i18n/fr.po b/partner_firstname/i18n/fr.po
new file mode 100644
index 000000000..bcd457166
--- /dev/null
+++ b/partner_firstname/i18n/fr.po
@@ -0,0 +1,52 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * partner_firstname
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-04 10:36+0000\n"
+"PO-Revision-Date: 2013-02-04 10:36+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: partner_firstname
+#: code:addons/partner_firstname/partner.py:81
+#: code:addons/partner_firstname/res_user.py:35
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
+#, python-format
+msgid "%s (copy)"
+msgstr "%s (copie)"
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_users
+msgid "Users"
+msgstr "Utilisateur"
+
+#. module: partner_firstname
+#: field:res.partner,firstname:0
+msgid "Firstname"
+msgstr "Prénom"
+
+#. module: partner_firstname
+#: field:res.partner,lastname:0
+msgid "Lastname"
+msgstr "Nom de famille"
+
+#. module: partner_firstname
+#: view:res.partner:0
+msgid "Is a Company?"
+msgstr "Est une société?"
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_partner
+msgid "Partner"
+msgstr "Partenaire"
diff --git a/partner_firstname/i18n/nl.po b/partner_firstname/i18n/nl.po
new file mode 100644
index 000000000..cd798ec82
--- /dev/null
+++ b/partner_firstname/i18n/nl.po
@@ -0,0 +1,52 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * partner_firstname
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-04 10:36+0000\n"
+"PO-Revision-Date: 2013-02-04 10:36+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: partner_firstname
+#: code:addons/partner_firstname/partner.py:81
+#: code:addons/partner_firstname/res_user.py:35
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
+#, python-format
+msgid "%s (copy)"
+msgstr "%s (kopie)"
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_users
+msgid "Users"
+msgstr "Gebruikers"
+
+#. module: partner_firstname
+#: field:res.partner,firstname:0
+msgid "Firstname"
+msgstr "Voornaam"
+
+#. module: partner_firstname
+#: field:res.partner,lastname:0
+msgid "Lastname"
+msgstr "Achternaam"
+
+#. module: partner_firstname
+#: view:res.partner:0
+msgid "Is a Company?"
+msgstr "Is een bedrijf?"
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_partner
+msgid "Partner"
+msgstr "Relatie"
diff --git a/partner_firstname/i18n/partner_firstname.pot b/partner_firstname/i18n/partner_firstname.pot
new file mode 100644
index 000000000..ab75c787a
--- /dev/null
+++ b/partner_firstname/i18n/partner_firstname.pot
@@ -0,0 +1,53 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * partner_firstname
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-22 14:09+0000\n"
+"PO-Revision-Date: 2014-01-22 14:09+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: partner_firstname
+#: code:addons/partner_firstname/partner.py:81
+#: code:addons/partner_firstname/res_user.py:35
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
+#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
+#, python-format
+msgid "%s (copy)"
+msgstr ""
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_users
+msgid "Users"
+msgstr ""
+
+#. module: partner_firstname
+#: field:res.partner,firstname:0
+msgid "Firstname"
+msgstr ""
+
+#. module: partner_firstname
+#: field:res.partner,lastname:0
+msgid "Lastname"
+msgstr ""
+
+#. module: partner_firstname
+#: view:res.partner:0
+msgid "Is a Company?"
+msgstr ""
+
+#. module: partner_firstname
+#: model:ir.model,name:partner_firstname.model_res_partner
+msgid "Partner"
+msgstr ""
+
diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py
new file mode 100644
index 000000000..4be5cca8d
--- /dev/null
+++ b/partner_firstname/partner.py
@@ -0,0 +1,134 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi. Copyright Camptocamp SA
+# Copyright (C) 2014 Agile Business Group ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class ResPartner(orm.Model):
+ """Adds lastname and firstname, name become a stored function field"""
+
+ _inherit = 'res.partner'
+
+ def _set_default_value_on_column(self, cr, column_name, context=None):
+ res = super(ResPartner, self)._set_default_value_on_column(
+ cr, column_name, context=context)
+ if column_name == 'lastname':
+ cr.execute('UPDATE res_partner SET lastname = name WHERE name '
+ 'IS NOT NULL AND lastname IS NULL')
+ cr.execute('ALTER TABLE res_partner ALTER COLUMN lastname '
+ 'SET NOT NULL')
+ _logger.info("NOT NULL constraint for "
+ "res_partner.lastname correctly set")
+ return res
+
+ def _prepare_name_custom(self, cursor, uid, partner, context=None):
+ """
+ This function is designed to be inherited in a custom module
+ """
+ names = (partner.lastname, partner.firstname)
+ fullname = " ".join([s for s in names if s])
+ return fullname
+
+ def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None):
+ res = {}
+ for partner in self.browse(cursor, uid, ids, context=context):
+ res[partner.id] = self._prepare_name_custom(
+ cursor, uid, partner, context=context)
+ return res
+
+ def _write_name(
+ self, cursor, uid, partner_id, field_name, field_value, arg,
+ context=None
+ ):
+ """
+ Try to reverse the effect of _compute_name_custom:
+ * if the partner is not a company and the firstname does not change in
+ the new name then firstname remains untouched and lastname is updated
+ accordingly
+ * otherwise lastname=new name and firstname=False
+ In addition an heuristic avoids to keep a firstname without a non-blank
+ lastname
+ """
+ field_value = (
+ field_value and not field_value.isspace() and field_value or False)
+ vals = {'lastname': field_value, 'firstname': False}
+ if field_value:
+ flds = self.read(
+ cursor, uid, [partner_id], ['firstname', 'is_company'],
+ context=context)[0]
+ if not flds['is_company']:
+ to_check = ' %s' % flds['firstname']
+ if field_value.endswith(to_check):
+ ln = field_value[:-len(to_check)].strip()
+ if ln:
+ vals['lastname'] = ln
+ del(vals['firstname'])
+ else:
+ # If the lastname is deleted from the new name
+ # then the firstname becomes the lastname
+ vals['lastname'] = flds['firstname']
+
+ return self.write(cursor, uid, partner_id, vals, context=context)
+
+ def copy_data(self, cr, uid, _id, default=None, context=None):
+ """
+ Avoid to replicate the firstname into the name when duplicating a
+ partner
+ """
+ default = default or {}
+ if not default.get('lastname'):
+ default = default.copy()
+ default['lastname'] = (
+ _('%s (copy)') % self.read(
+ cr, uid, [_id], ['lastname'], context=context
+ )[0]['lastname']
+ )
+ if default.get('name'):
+ del(default['name'])
+ return super(ResPartner, self).copy_data(
+ cr, uid, _id, default, context=context)
+
+ def create(self, cursor, uid, vals, context=None):
+ """
+ To support data backward compatibility we have to keep this overwrite
+ even if we use fnct_inv: otherwise we can't create entry because
+ lastname is mandatory and module will not install if there is demo data
+ """
+ to_use = vals
+ if 'name' in vals:
+ corr_vals = vals.copy()
+ if vals.get('name'):
+ corr_vals['lastname'] = corr_vals['name']
+ del(corr_vals['name'])
+ to_use = corr_vals
+ return super(ResPartner, self).create(
+ cursor, uid, to_use, context=context)
+
+ _columns = {'name': fields.function(_compute_name_custom, string="Name",
+ type="char", store=True,
+ select=True, readonly=True,
+ fnct_inv=_write_name),
+
+ 'firstname': fields.char("Firstname"),
+ 'lastname': fields.char("Lastname", required=True)}
diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml
new file mode 100644
index 000000000..9a88c6e80
--- /dev/null
+++ b/partner_firstname/partner_view.xml
@@ -0,0 +1,62 @@
+
+
+
+ res.partner.simplified.form.firstname
+ res.partner
+
+
+
+ {'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]}
+
+
+
+
+
+
+
+
+
+
+
+ res.partner.form.firstname
+ res.partner
+
+
+
+ {'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/partner_firstname/res_user.py b/partner_firstname/res_user.py
new file mode 100644
index 000000000..a84f5b18c
--- /dev/null
+++ b/partner_firstname/res_user.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi. Copyright Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from openerp.osv import orm
+from openerp.tools.translate import _
+
+
+class ResUsers(orm.Model):
+
+ _inherit = 'res.users'
+
+ def copy_data(self, cr, uid, _id, default=None, context=None):
+ """
+ Avoid to replicate the firstname into the name when duplicating a user
+ """
+ default = default or {}
+ if not default.get('lastname'):
+ default = default.copy()
+ default['lastname'] = (
+ _('%s (copy)') % self.read(
+ cr, uid, [_id], ['lastname'], context=context
+ )[0]['lastname']
+ )
+ if default.get('name'):
+ del(default['name'])
+ return super(ResUsers, self).copy_data(
+ cr, uid, _id, default, context=context)
diff --git a/partner_firstname/res_user_view.xml b/partner_firstname/res_user_view.xml
new file mode 100644
index 000000000..56f91507c
--- /dev/null
+++ b/partner_firstname/res_user_view.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+ res.users.form.firstname
+ res.users
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/partner_firstname/tests/__init__.py b/partner_firstname/tests/__init__.py
new file mode 100644
index 000000000..c0902dd38
--- /dev/null
+++ b/partner_firstname/tests/__init__.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Authors: Nemry Jonathan
+# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
+# All Rights Reserved
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs.
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly advised to contact a Free Software
+# Service Company.
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+import test_partner_firstname
+
+checks = [
+ test_partner_firstname
+]
diff --git a/partner_firstname/tests/test_partner_firstname.py b/partner_firstname/tests/test_partner_firstname.py
new file mode 100644
index 000000000..a4bac1ee0
--- /dev/null
+++ b/partner_firstname/tests/test_partner_firstname.py
@@ -0,0 +1,153 @@
+# -*- coding: utf-8 -*-
+#
+#
+# Authors: Nemry Jonathan
+# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
+# All Rights Reserved
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs.
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly advised to contact a Free Software
+# Service Company.
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#
+import openerp.tests.common as common
+
+from openerp.tools.translate import _
+
+
+class test_partner_firstname(common.TransactionCase):
+
+ def setUp(self):
+ super(test_partner_firstname, self).setUp()
+
+ self.registry('ir.model').clear_caches()
+ self.registry('ir.model.data').clear_caches()
+
+ self.user_model = self.registry("res.users")
+ self.partner_model = self.registry("res.partner")
+ self.fields_partner = {
+ 'lastname': 'lastname', 'firstname': 'firstname'}
+ self.fields_user = {
+ 'name': 'lastname', 'login': 'v5Ue4Tql0Pm67KX05g25A'}
+
+ self.context = self.user_model.context_get(self.cr, self.uid)
+
+ def test_copy_partner(self):
+ cr, uid, context = self.cr, self.uid, self.context
+ res_id = self.partner_model.create(
+ cr, uid, self.fields_partner, context=context)
+ res_id = self.partner_model.copy(
+ cr, uid, res_id, default={}, context=context)
+ vals = self.partner_model.read(cr, uid, [res_id], [
+ 'name', 'lastname', 'firstname'], context=context)[0]
+
+ self.assertEqual(
+ vals['name'],
+ _('%s (copy)') % 'lastname' + " firstname",
+ 'Copy of the partner failed with wrong name'
+ )
+ self.assertEqual(
+ vals['lastname'],
+ _('%s (copy)') % 'lastname',
+ 'Copy of the partner failed with wrong lastname'
+ )
+ self.assertEqual(vals['firstname'], 'firstname',
+ 'Copy of the partner failed with wrong firstname')
+
+ def test_copy_user(self):
+ cr, uid, context = self.cr, self.uid, self.context
+ # create a user
+ res_id = self.user_model.create(
+ cr, uid, self.fields_user, context=context)
+ # get the related partner id and add it a firstname
+ flds = self.user_model.read(
+ cr, uid, [res_id], ['partner_id'], context=context)[0]
+ self.partner_model.write(cr, uid, flds['partner_id'][
+ 0], {'firstname': 'firstname'}, context=context)
+ # copy the user and compare result
+ res_id = self.user_model.copy(
+ cr, uid, res_id, default={}, context=context)
+ vals = self.user_model.read(
+ cr, uid, [res_id], ['name', 'lastname', 'firstname'],
+ context=context)[0]
+
+ self.assertEqual(
+ vals['name'],
+ _('%s (copy)') % 'lastname' + ' firstname',
+ 'Copy of the user failed with wrong name'
+ )
+ self.assertEqual(
+ vals['lastname'], _('%s (copy)') %
+ 'lastname', 'Copy of the user failed with wrong lastname')
+ self.assertEqual(vals['firstname'], 'firstname',
+ 'Copy of the user failed with wrong firstname')
+
+ def test_update_user_lastname(self):
+ cr, uid, context = self.cr, self.uid, self.context
+ # create a user
+ res_id = self.user_model.create(
+ cr, uid, self.fields_user, context=context)
+ # get the related partner id and add it a firstname
+ flds = self.user_model.read(
+ cr, uid, [res_id], ['partner_id'], context=context)[0]
+ self.partner_model.write(
+ cr, uid, flds['partner_id'][0], {'firstname': 'firstname'},
+ context=context)
+ self.user_model.write(
+ cr, uid, res_id, {'name': 'change firstname'}, context=context)
+ vals = self.user_model.read(
+ cr, uid, [res_id], ['name', 'lastname', 'firstname'],
+ context=context)[0]
+
+ self.assertEqual(vals['name'], 'change firstname',
+ 'Update of the user lastname failed with wrong name')
+ self.assertEqual(
+ vals['lastname'], 'change',
+ 'Update of the user lastname failed with wrong lastname')
+ self.assertEqual(
+ vals['firstname'], 'firstname',
+ 'Update of the user lastname failed with wrong firstname')
+
+ def test_update_user_firstname(self):
+ cr, uid, context = self.cr, self.uid, self.context
+ # create a user
+ res_id = self.user_model.create(
+ cr, uid, self.fields_user, context=context)
+ # get the related partner id and add it a firstname
+ flds = self.user_model.read(
+ cr, uid, [res_id], ['partner_id'], context=context)[0]
+ self.partner_model.write(
+ cr, uid, flds['partner_id'][0], {'firstname': 'firstname'},
+ context=context)
+ self.user_model.write(
+ cr, uid, res_id, {'name': 'lastname other'}, context=context)
+ vals = self.user_model.read(
+ cr, uid, [res_id], ['name', 'lastname', 'firstname'],
+ context=context)[0]
+
+ self.assertEqual(
+ vals['name'], 'lastname other',
+ 'Update of the user firstname failed with wrong name')
+ self.assertEqual(
+ vals['lastname'], 'lastname other',
+ 'Update of the user firstname failed with wrong lastname')
+ self.assertFalse(
+ vals['firstname'],
+ 'Update of the user firstname failed with wrong firstname')