From 045141d1a7d8e8a031956126f1f51e9f660279db Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Jan 2013 12:06:45 +0100 Subject: [PATCH 001/122] [ADD] partner_firstname addons --- partner_firstname/__init__.py | 20 +++++++++ partner_firstname/__openerp__.py | 37 +++++++++++++++++ partner_firstname/partner.py | 65 ++++++++++++++++++++++++++++++ partner_firstname/partner_view.xml | 32 +++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 partner_firstname/__init__.py create mode 100644 partner_firstname/__openerp__.py create mode 100644 partner_firstname/partner.py create mode 100644 partner_firstname/partner_view.xml diff --git a/partner_firstname/__init__.py b/partner_firstname/__init__.py new file mode 100644 index 00000000000..716a72b0bea --- /dev/null +++ b/partner_firstname/__init__.py @@ -0,0 +1,20 @@ +# -*- encoding: 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 diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py new file mode 100644 index 00000000000..ef84583f8b5 --- /dev/null +++ b/partner_firstname/__openerp__.py @@ -0,0 +1,37 @@ +# -*- encoding: 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': """Split firstname and lastname on res.partner. +The field name becomes a stored function field concatenating lastname, firstname. +The create write function are overwritten to support compatibility +""", + 'version': '1.0', + 'author': 'Camptocamp', + 'category': 'MISC', + 'website': 'http://www.camptocamp.com', + 'depends': ['base'], + 'data': ['partner_view.xml'], + 'demo': [], + 'test': [], + 'auto_install': False, + 'installable': True, + 'images': [] +} diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py new file mode 100644 index 00000000000..a7f354cab4e --- /dev/null +++ b/partner_firstname/partner.py @@ -0,0 +1,65 @@ +# -*- encoding: 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.orm import Model, fields + + +class ResPartner(Model): + """Adds lastname and firstname, name become a stored function field""" + + _inherit = 'res.partner' + + def init(self, cursor): + cursor.execute('SELECT id FROM res_partner WHERE lastname IS NOT NULL') + if not cursor.fetchone(): + cursor.execute('UPDATE res_partner set lastname = name WHERE name IS NOT NULL') + + def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): + res = {} + for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): + name = rec['lastname'] + (u" " + rec['firstname'] if rec['firstname'] else u"") + res[rec['id']] = name + return res + + _columns = {'name': fields.function(_compute_name_custom, string="Name", + type="char", store=True, + select=True, readonly=True), + + 'firstname': fields.char("Firstname"), + 'lastname': fields.char("Lastname", required=True)} + + def create(self, cursor, uid, vals, context=None): + """To support data backward compatibility""" + to_use = vals + if vals.get('name'): + corr_vals = vals.copy() + 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) + + def write(self, cursor, uid, ids, vals, context=None): + """To support data backward compatibility""" + to_use = vals + if vals.get('name'): + corr_vals = vals.copy() + corr_vals['lastname'] = corr_vals['name'] + del(corr_vals['name']) + to_use = corr_vals + return super(ResPartner, self).write(cursor, uid, ids, to_use, context=context) diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml new file mode 100644 index 00000000000..4052da4bb85 --- /dev/null +++ b/partner_firstname/partner_view.xml @@ -0,0 +1,32 @@ + + + + res.partner.simplified.form.firstname + res.partner + + + + + + + + + + + + + res.partner.form.firstname + res.partner + + + + + + + + + + + + + From 9f64b0fedafed1aae61b93ae6a9e0f14765a101e Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 14 Jan 2013 15:44:05 +0100 Subject: [PATCH 002/122] [REV] remove the previous revision, the merge proposal has been merged too early --- partner_firstname/__init__.py | 20 --------- partner_firstname/__openerp__.py | 37 ----------------- partner_firstname/partner.py | 65 ------------------------------ partner_firstname/partner_view.xml | 32 --------------- 4 files changed, 154 deletions(-) delete mode 100644 partner_firstname/__init__.py delete mode 100644 partner_firstname/__openerp__.py delete mode 100644 partner_firstname/partner.py delete mode 100644 partner_firstname/partner_view.xml diff --git a/partner_firstname/__init__.py b/partner_firstname/__init__.py deleted file mode 100644 index 716a72b0bea..00000000000 --- a/partner_firstname/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- encoding: 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 diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py deleted file mode 100644 index ef84583f8b5..00000000000 --- a/partner_firstname/__openerp__.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- encoding: 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': """Split firstname and lastname on res.partner. -The field name becomes a stored function field concatenating lastname, firstname. -The create write function are overwritten to support compatibility -""", - 'version': '1.0', - 'author': 'Camptocamp', - 'category': 'MISC', - 'website': 'http://www.camptocamp.com', - 'depends': ['base'], - 'data': ['partner_view.xml'], - 'demo': [], - 'test': [], - 'auto_install': False, - 'installable': True, - 'images': [] -} diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py deleted file mode 100644 index a7f354cab4e..00000000000 --- a/partner_firstname/partner.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- encoding: 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.orm import Model, fields - - -class ResPartner(Model): - """Adds lastname and firstname, name become a stored function field""" - - _inherit = 'res.partner' - - def init(self, cursor): - cursor.execute('SELECT id FROM res_partner WHERE lastname IS NOT NULL') - if not cursor.fetchone(): - cursor.execute('UPDATE res_partner set lastname = name WHERE name IS NOT NULL') - - def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): - res = {} - for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): - name = rec['lastname'] + (u" " + rec['firstname'] if rec['firstname'] else u"") - res[rec['id']] = name - return res - - _columns = {'name': fields.function(_compute_name_custom, string="Name", - type="char", store=True, - select=True, readonly=True), - - 'firstname': fields.char("Firstname"), - 'lastname': fields.char("Lastname", required=True)} - - def create(self, cursor, uid, vals, context=None): - """To support data backward compatibility""" - to_use = vals - if vals.get('name'): - corr_vals = vals.copy() - 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) - - def write(self, cursor, uid, ids, vals, context=None): - """To support data backward compatibility""" - to_use = vals - if vals.get('name'): - corr_vals = vals.copy() - corr_vals['lastname'] = corr_vals['name'] - del(corr_vals['name']) - to_use = corr_vals - return super(ResPartner, self).write(cursor, uid, ids, to_use, context=context) diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml deleted file mode 100644 index 4052da4bb85..00000000000 --- a/partner_firstname/partner_view.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - res.partner.simplified.form.firstname - res.partner - - - - - - - - - - - - - res.partner.form.firstname - res.partner - - - - - - - - - - - - - From c74f431405c6092e8bb9b5fefc1a3c48d682e97f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2013 14:37:23 +0100 Subject: [PATCH 003/122] [ADD] partner_firstname module --- partner_firstname/__init__.py | 20 ++++++++++++ partner_firstname/__openerp__.py | 36 ++++++++++++++++++++++ partner_firstname/i18n/de.po | 31 +++++++++++++++++++ partner_firstname/i18n/en.po | 32 +++++++++++++++++++ partner_firstname/i18n/fr.po | 31 +++++++++++++++++++ partner_firstname/partner.py | 49 ++++++++++++++++++++++++++++++ partner_firstname/partner_view.xml | 37 ++++++++++++++++++++++ 7 files changed, 236 insertions(+) create mode 100644 partner_firstname/__init__.py create mode 100644 partner_firstname/__openerp__.py create mode 100644 partner_firstname/i18n/de.po create mode 100644 partner_firstname/i18n/en.po create mode 100644 partner_firstname/i18n/fr.po create mode 100644 partner_firstname/partner.py create mode 100644 partner_firstname/partner_view.xml diff --git a/partner_firstname/__init__.py b/partner_firstname/__init__.py new file mode 100644 index 00000000000..716a72b0bea --- /dev/null +++ b/partner_firstname/__init__.py @@ -0,0 +1,20 @@ +# -*- encoding: 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 diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py new file mode 100644 index 00000000000..78fe5b24534 --- /dev/null +++ b/partner_firstname/__openerp__.py @@ -0,0 +1,36 @@ +# -*- encoding: 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': """Split first name last name on res.partner. +The field name become a stored function field concatenating lastname, firstname +""", + 'version': '1.0', + 'author': 'Camptocamp', + 'category': 'MISC', + 'website': 'http://www.camptocamp.com', + 'depends': ['base'], + 'data': ['partner_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 00000000000..5565405d57b --- /dev/null +++ b/partner_firstname/i18n/de.po @@ -0,0 +1,31 @@ +# 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 +#: field:res.partner,lastname:0 +msgid "Lastname" +msgstr "Name" + +#. module: partner_firstname +#: field:res.partner,firstname:0 +msgid "Firstname" +msgstr "Vorname" + +#. 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 00000000000..26e710fec2d --- /dev/null +++ b/partner_firstname/i18n/en.po @@ -0,0 +1,32 @@ +# 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 +#: field:res.partner,lastname:0 +msgid "Lastname" +msgstr "Lastname" + +#. module: partner_firstname +#: field:res.partner,firstname:0 +msgid "Firstname" +msgstr "Firstname" + +#. 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 00000000000..5155afb0c62 --- /dev/null +++ b/partner_firstname/i18n/fr.po @@ -0,0 +1,31 @@ +# 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 +#: field:res.partner,lastname:0 +msgid "Lastname" +msgstr "Nom" + +#. module: partner_firstname +#: field:res.partner,firstname:0 +msgid "Firstname" +msgstr "Prénom" + +#. module: partner_firstname +#: model:ir.model,name:partner_firstname.model_res_partner +msgid "Partner" +msgstr "Partenaire" diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py new file mode 100644 index 00000000000..31b54220a87 --- /dev/null +++ b/partner_firstname/partner.py @@ -0,0 +1,49 @@ +# -*- encoding: 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.orm import Model, fields + + +class ResPartner(Model): + """Adds lastname and firstname, name become a stored function field""" + + _inherit = 'res.partner' + + def init(self, cursor): + cursor.execute('SELECT id FROM res_partner WHERE lastname IS NOT NULL Limit 1') + if not cursor.fetchone(): + cursor.execute('UPDATE res_partner set lastname = name WHERE name IS NOT NULL') + + def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): + res = {} + for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): + name = rec['lastname'] + (u" " + rec['firstname'] if rec['firstname'] else u"") + res[rec['id']] = name + return res + + def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None): + return self.write(cursor, uid, partner_id, {'lastname': field_value}) + + _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 00000000000..d58edf63903 --- /dev/null +++ b/partner_firstname/partner_view.xml @@ -0,0 +1,37 @@ + + + + res.partner.simplified.form.firstname + res.partner + + + + + + + + + + + + + res.partner.form.firstname + res.partner + + + + + + + + + + + + + + + + + + From 28ad89653752ffb9063040e7aeefe45a7380c3dc Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2013 14:49:26 +0100 Subject: [PATCH 004/122] [FIX] heading coding definition --- partner_firstname/__init__.py | 2 +- partner_firstname/__openerp__.py | 2 +- partner_firstname/partner.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/partner_firstname/__init__.py b/partner_firstname/__init__.py index 716a72b0bea..0df41cead3f 100644 --- a/partner_firstname/__init__.py +++ b/partner_firstname/__init__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi. Copyright Camptocamp SA diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py index 78fe5b24534..a75b13d3dc1 100644 --- a/partner_firstname/__openerp__.py +++ b/partner_firstname/__openerp__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi. Copyright Camptocamp SA diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index 31b54220a87..b36b8b83fe6 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi. Copyright Camptocamp SA From e55aaed825e973e9af1583623a5225b524d5fa4a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2013 15:19:19 +0100 Subject: [PATCH 005/122] [FIX] partner_firstname can't create partner as lastname is required --- partner_firstname/partner.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index b36b8b83fe6..ded8ab83279 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -40,6 +40,18 @@ def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None): return self.write(cursor, uid, partner_id, {'lastname': field_value}) + 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 else we can't create entry as lastname is mandatory and module + will not install if there is demo data""" + to_use = vals + if vals.get('name'): + corr_vals = vals.copy() + 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, From 52cbb73ea594b4fc313da78e74947a37b2e36e10 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Tue, 5 Feb 2013 09:26:54 +0100 Subject: [PATCH 006/122] [IMP] small improvements in module description and docstrings --- partner_firstname/__openerp__.py | 5 +++-- partner_firstname/partner.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py index a75b13d3dc1..b2cae6906dc 100644 --- a/partner_firstname/__openerp__.py +++ b/partner_firstname/__openerp__.py @@ -19,8 +19,9 @@ ############################################################################## {'name': 'Partner first name, last name', - 'description': """Split first name last name on res.partner. -The field name become a stored function field concatenating lastname, firstname + 'description': """Split first name and last name on res.partner. + +The field 'name' becomes a stored function field concatenating lastname, firstname """, 'version': '1.0', 'author': 'Camptocamp', diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index ded8ab83279..9b44641d26c 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -42,7 +42,7 @@ def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, con 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 else we can't create entry as lastname is mandatory and module + 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 vals.get('name'): From 4e2e2abdefffdc6223eef42dd00ecc3e75cc6838 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Feb 2013 21:58:07 +0100 Subject: [PATCH 007/122] [FIX] user creation from res_user form --- partner_firstname/__init__.py | 1 + partner_firstname/res_user.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 partner_firstname/res_user.py diff --git a/partner_firstname/__init__.py b/partner_firstname/__init__.py index 0df41cead3f..ec7a9bae42f 100644 --- a/partner_firstname/__init__.py +++ b/partner_firstname/__init__.py @@ -18,3 +18,4 @@ # ############################################################################## from . import partner +from . import res_user diff --git a/partner_firstname/res_user.py b/partner_firstname/res_user.py new file mode 100644 index 00000000000..71cf38c1fb2 --- /dev/null +++ b/partner_firstname/res_user.py @@ -0,0 +1,31 @@ +# -*- encoding: 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 + + +class ResUsers(orm.Model): + """Allows user creation from user form as + name is not in form""" + + _inherit = 'res.users' + + def create(self, cursor, uid, vals, context=None): + vals['name'] = vals['login'] + return super(ResUsers, self).create(cursor, uid, vals, context=context) \ No newline at end of file From af492eb2794d1b1d186c11509988324cff34c382 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Feb 2013 22:01:37 +0100 Subject: [PATCH 008/122] [MRG] Typo --- partner_firstname/partner_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml index d58edf63903..0e3de5f584e 100644 --- a/partner_firstname/partner_view.xml +++ b/partner_firstname/partner_view.xml @@ -25,7 +25,7 @@ - + From 2eaa49d5135acf5074600e99d24a9c1089913821 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 20 Feb 2013 13:43:45 +0100 Subject: [PATCH 009/122] [FIX] partner_firstname name not editable in user view --- partner_firstname/__openerp__.py | 7 +++++-- partner_firstname/res_user.py | 7 ++++--- partner_firstname/res_user_view.xml | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 partner_firstname/res_user_view.xml diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py index b2cae6906dc..17d7d93e57c 100644 --- a/partner_firstname/__openerp__.py +++ b/partner_firstname/__openerp__.py @@ -23,12 +23,15 @@ The field 'name' becomes a stored function field concatenating lastname, firstname """, - 'version': '1.0', + 'version': '1.0.1', 'author': 'Camptocamp', 'category': 'MISC', 'website': 'http://www.camptocamp.com', 'depends': ['base'], - 'data': ['partner_view.xml'], + 'data': [ + 'partner_view.xml', + 'res_user_view.xml', + ], 'demo': [], 'test': [], 'auto_install': False, diff --git a/partner_firstname/res_user.py b/partner_firstname/res_user.py index 71cf38c1fb2..8bb0934142b 100644 --- a/partner_firstname/res_user.py +++ b/partner_firstname/res_user.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi. Copyright Camptocamp SA @@ -27,5 +27,6 @@ class ResUsers(orm.Model): _inherit = 'res.users' def create(self, cursor, uid, vals, context=None): - vals['name'] = vals['login'] - return super(ResUsers, self).create(cursor, uid, vals, context=context) \ No newline at end of file + if not 'name' in vals or not vals['name']: + vals['name'] = vals['login'] + return super(ResUsers, self).create(cursor, uid, vals, context=context) diff --git a/partner_firstname/res_user_view.xml b/partner_firstname/res_user_view.xml new file mode 100644 index 00000000000..22fd1b57be3 --- /dev/null +++ b/partner_firstname/res_user_view.xml @@ -0,0 +1,15 @@ + + + + + res.users.form.firstname + res.users + + + + False + + + + + From bde32e02b706f8121f497438f6e9c9e5d7ed1390 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 20 Feb 2013 15:00:17 +0100 Subject: [PATCH 010/122] [IMP] partner_firstname - less steps in partner vals(e) --- partner_firstname/res_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partner_firstname/res_user.py b/partner_firstname/res_user.py index 8bb0934142b..d1d3a78e43f 100644 --- a/partner_firstname/res_user.py +++ b/partner_firstname/res_user.py @@ -27,6 +27,6 @@ class ResUsers(orm.Model): _inherit = 'res.users' def create(self, cursor, uid, vals, context=None): - if not 'name' in vals or not vals['name']: + if not vals.get('name'): vals['name'] = vals['login'] return super(ResUsers, self).create(cursor, uid, vals, context=context) From aed00f22e84cd0e7af92550c284ac2d76105c1d1 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 29 Apr 2013 17:14:38 +0200 Subject: [PATCH 011/122] [FIX] partner_firstname - adapt partner form inherit to new partner form --- partner_firstname/partner_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml index 0e3de5f584e..d92959c2df2 100644 --- a/partner_firstname/partner_view.xml +++ b/partner_firstname/partner_view.xml @@ -26,7 +26,7 @@ - + From 4f3d2c9b8d0bc9b37bfb91a31e7540961490042c Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Tue, 30 Apr 2013 10:10:08 +0200 Subject: [PATCH 012/122] [IMP] partner_firstname - giving some meaning to a comment --- partner_firstname/partner_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml index d92959c2df2..e13bdc50ce7 100644 --- a/partner_firstname/partner_view.xml +++ b/partner_firstname/partner_view.xml @@ -25,7 +25,7 @@ - + From 6b0ddd40da315c9c26aea5000043c06562d2791a Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Fri, 17 May 2013 16:37:49 +0200 Subject: [PATCH 013/122] [FIX] firstname lastname fix if empty --- partner_firstname/partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index 9b44641d26c..59973aa603f 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -33,7 +33,7 @@ def init(self, cursor): def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): res = {} for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): - name = rec['lastname'] + (u" " + rec['firstname'] if rec['firstname'] else u"") + name = rec['lastname'] if rec['lastname'] else u"" + (u" " + rec['firstname'] if rec['firstname'] else u"") res[rec['id']] = name return res From 6bd6ebad12ba83007af313e4fde412adf3c72a70 Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Tue, 21 May 2013 15:27:17 +0200 Subject: [PATCH 014/122] [FIX] search --- partner_firstname/partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index 59973aa603f..304b7943bf5 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -33,7 +33,7 @@ def init(self, cursor): def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): res = {} for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): - name = rec['lastname'] if rec['lastname'] else u"" + (u" " + rec['firstname'] if rec['firstname'] else u"") + name = '%s %s'%(rec['lastname'] if rec['lastname'] else u"",rec['firstname'] if rec['firstname'] else u"") res[rec['id']] = name return res From cad720824a856744e95d64caaef400db2ec3de9f Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Tue, 21 May 2013 16:38:03 +0200 Subject: [PATCH 015/122] [FIX] typo : fix instruction length --- partner_firstname/partner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index 304b7943bf5..eb039f66c0a 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -33,7 +33,8 @@ def init(self, cursor): def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): res = {} for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): - name = '%s %s'%(rec['lastname'] if rec['lastname'] else u"",rec['firstname'] if rec['firstname'] else u"") + name = '%s %s'%(rec['lastname'] if rec['lastname'] else u"", + rec['firstname'] if rec['firstname'] else u"") res[rec['id']] = name return res From af80ae43ef23daa9ef586290679ef3a6210a951b Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 29 Jul 2013 16:34:21 +0200 Subject: [PATCH 016/122] [FIX] partner_firstname - error when lastname being empty with demo data, migrated data or imported data --- partner_firstname/partner.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index eb039f66c0a..ca9e829c052 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -33,9 +33,10 @@ def init(self, cursor): def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): res = {} for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): - name = '%s %s'%(rec['lastname'] if rec['lastname'] else u"", - rec['firstname'] if rec['firstname'] else u"") - res[rec['id']] = name + names = [rec['lastname'], + rec['firstname']] + fullname = " ".join([s for s in names if s]) + res[rec['id']] = fullname return res def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None): From 8498816a26f42cb634d494b7bc9ce16af41de10d Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 12 Aug 2013 08:15:02 +0200 Subject: [PATCH 017/122] [FIX] use a tuple instead of a list --- partner_firstname/partner.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index ca9e829c052..e38b2ec667d 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -33,8 +33,7 @@ def init(self, cursor): def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): res = {} for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): - names = [rec['lastname'], - rec['firstname']] + names = (rec['lastname'], rec['firstname']) fullname = " ".join([s for s in names if s]) res[rec['id']] = fullname return res From 8e6999e5c601744b146928201fcb1465173c4148 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 12 Aug 2013 08:17:49 +0200 Subject: [PATCH 018/122] [FIX] missing propagation of the context --- partner_firstname/partner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index e38b2ec667d..3a14e3d4635 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -32,7 +32,9 @@ def init(self, cursor): def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): res = {} - for rec in self.read(cursor, uid, ids, ['firstname', 'lastname']): + partners = self.read(cursor, uid, ids, + ['firstname', 'lastname'], context=context) + for rec in partners: names = (rec['lastname'], rec['firstname']) fullname = " ".join([s for s in names if s]) res[rec['id']] = fullname From 972a38add9abed7e3e89e0e99e30112d67e6190c Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 12 Aug 2013 08:18:39 +0200 Subject: [PATCH 019/122] [FIX] missing propagation of the context #2 --- partner_firstname/partner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index 3a14e3d4635..42fed16eb46 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -41,7 +41,8 @@ def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): return res def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None): - return self.write(cursor, uid, partner_id, {'lastname': field_value}) + return self.write(cursor, uid, partner_id, + {'lastname': field_value}, context=context) def create(self, cursor, uid, vals, context=None): """To support data backward compatibility we have to keep this overwrite even if we From d186798edba56b75efe0fa292b344d3f019409f1 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 1 Oct 2013 13:14:03 +0200 Subject: [PATCH 020/122] [IMP] don't show first/last name fields for companies --- partner_firstname/partner_view.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml index e13bdc50ce7..ce99f4438d5 100644 --- a/partner_firstname/partner_view.xml +++ b/partner_firstname/partner_view.xml @@ -5,8 +5,11 @@ res.partner + + {'readonly': [('is_company', '=', False)]} + - + @@ -19,8 +22,11 @@ res.partner + + {'readonly': [('is_company', '=', False)]} + - + From 14f833cfa1266f7e01869ca19f13a98dbeb2e682 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 1 Oct 2013 13:32:16 +0200 Subject: [PATCH 021/122] [FIX] get required attributes right for companies and non-companies --- partner_firstname/partner_view.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml index ce99f4438d5..973554e70dd 100644 --- a/partner_firstname/partner_view.xml +++ b/partner_firstname/partner_view.xml @@ -6,12 +6,12 @@ - {'readonly': [('is_company', '=', False)]} + {'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]} - - + + @@ -23,11 +23,11 @@ - {'readonly': [('is_company', '=', False)]} + {'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]} - + From 13f6b5a9b6977c8137f65178df4dc63784424c50 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 3 Oct 2013 17:20:53 +0200 Subject: [PATCH 022/122] [ADD] Dutch translation --- partner_firstname/i18n/nl.po | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 partner_firstname/i18n/nl.po diff --git a/partner_firstname/i18n/nl.po b/partner_firstname/i18n/nl.po new file mode 100644 index 00000000000..898d22c22c4 --- /dev/null +++ b/partner_firstname/i18n/nl.po @@ -0,0 +1,31 @@ +# 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 +#: field:res.partner,lastname:0 +msgid "Lastname" +msgstr "Achternaam" + +#. module: partner_firstname +#: field:res.partner,firstname:0 +msgid "Firstname" +msgstr "Voornaam" + +#. module: partner_firstname +#: model:ir.model,name:partner_firstname.model_res_partner +msgid "Partner" +msgstr "Relatie" From bfbd51dafa49ae2a16816c9afb2565225cc928ab Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 3 Oct 2013 18:13:54 +0200 Subject: [PATCH 023/122] [ADD] translation template --- partner_firstname/i18n/partner_firstname.pot | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 partner_firstname/i18n/partner_firstname.pot diff --git a/partner_firstname/i18n/partner_firstname.pot b/partner_firstname/i18n/partner_firstname.pot new file mode 100644 index 00000000000..96518f7583e --- /dev/null +++ b/partner_firstname/i18n/partner_firstname.pot @@ -0,0 +1,32 @@ +# 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-10-03 16:09+0000\n" +"PO-Revision-Date: 2013-10-03 16: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 +#: field:res.partner,firstname:0 +msgid "Firstname" +msgstr "" + +#. module: partner_firstname +#: field:res.partner,lastname:0 +msgid "Lastname" +msgstr "" + +#. module: partner_firstname +#: model:ir.model,name:partner_firstname.model_res_partner +msgid "Partner" +msgstr "" + From fb08e74c1f9cf9943e8f87531556edab6c93f3ce Mon Sep 17 00:00:00 2001 From: Vincent Renaville Date: Wed, 13 Nov 2013 17:18:13 +0100 Subject: [PATCH 024/122] [FIX] layout for contact view (display Firstname and Lastname label) + add Is a company on contact view of a partner --- partner_firstname/partner_view.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml index 973554e70dd..8f0368373f3 100644 --- a/partner_firstname/partner_view.xml +++ b/partner_firstname/partner_view.xml @@ -32,10 +32,18 @@ - - + + + + + + + + + + From 0641647cc34bb303d5295173037e8d0183294c77 Mon Sep 17 00:00:00 2001 From: Jonathan Nemry Date: Wed, 22 Jan 2014 16:46:07 +0100 Subject: [PATCH 025/122] [FIX] Create Sql constraint anyway [CHG] Improve the _write_name method * trying to coerce to the correct lastname if the firstname is untouched * resetting the firstname if contact is a company [FIX] Avoid to replicate the firstname into the name when duplicating a partner [FIX] Avoid to replicate the firstname into the name when duplicating a user [CHG] Restore the required attribute of the field name in user form [CHG] Beautify the inner form for children contacts (placing fields as in the main form) [FIX] Allow edition of the field name in the inner form if child is a company --- partner_firstname/i18n/de.po | 17 ++++++++ partner_firstname/i18n/en.po | 24 ++++++++++-- partner_firstname/i18n/fr.po | 17 ++++++++ partner_firstname/i18n/nl.po | 17 ++++++++ partner_firstname/i18n/partner_firstname.pot | 21 +++++++++- partner_firstname/partner.py | 41 +++++++++++++++++--- partner_firstname/partner_view.xml | 19 +++++++-- partner_firstname/res_user.py | 18 ++++++--- partner_firstname/res_user_view.xml | 1 + 9 files changed, 154 insertions(+), 21 deletions(-) diff --git a/partner_firstname/i18n/de.po b/partner_firstname/i18n/de.po index 5565405d57b..65fdef123d4 100644 --- a/partner_firstname/i18n/de.po +++ b/partner_firstname/i18n/de.po @@ -15,6 +15,18 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: partner_firstname +#: code:addons/partner_firstname/partner.py:76 +#: code:addons/partner_firstname/res_user.py:35 +#, 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,lastname:0 msgid "Lastname" @@ -25,6 +37,11 @@ msgstr "Name" msgid "Firstname" msgstr "Vorname" +#. 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" diff --git a/partner_firstname/i18n/en.po b/partner_firstname/i18n/en.po index 26e710fec2d..53f3034f866 100644 --- a/partner_firstname/i18n/en.po +++ b/partner_firstname/i18n/en.po @@ -16,17 +16,33 @@ msgstr "" "Plural-Forms: \n" #. module: partner_firstname -#: field:res.partner,lastname:0 -msgid "Lastname" -msgstr "Lastname" +#: code:addons/partner_firstname/partner.py:76 +#: code:addons/partner_firstname/res_user.py:35 +#, 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 index 5155afb0c62..682b35041e6 100644 --- a/partner_firstname/i18n/fr.po +++ b/partner_firstname/i18n/fr.po @@ -15,6 +15,18 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: partner_firstname +#: code:addons/partner_firstname/partner.py:76 +#: code:addons/partner_firstname/res_user.py:35 +#, 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,lastname:0 msgid "Lastname" @@ -25,6 +37,11 @@ msgstr "Nom" msgid "Firstname" msgstr "Prénom" +#. 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" diff --git a/partner_firstname/i18n/nl.po b/partner_firstname/i18n/nl.po index 898d22c22c4..a8eb29ef40f 100644 --- a/partner_firstname/i18n/nl.po +++ b/partner_firstname/i18n/nl.po @@ -15,6 +15,18 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: partner_firstname +#: code:addons/partner_firstname/partner.py:76 +#: code:addons/partner_firstname/res_user.py:35 +#, 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,lastname:0 msgid "Lastname" @@ -25,6 +37,11 @@ msgstr "Achternaam" msgid "Firstname" msgstr "Voornaam" +#. 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" diff --git a/partner_firstname/i18n/partner_firstname.pot b/partner_firstname/i18n/partner_firstname.pot index 96518f7583e..52c9ec19051 100644 --- a/partner_firstname/i18n/partner_firstname.pot +++ b/partner_firstname/i18n/partner_firstname.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: OpenERP Server 7.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-10-03 16:09+0000\n" -"PO-Revision-Date: 2013-10-03 16:09+0000\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" @@ -15,6 +15,18 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: partner_firstname +#: code:addons/partner_firstname/partner.py:76 +#: code:addons/partner_firstname/res_user.py:35 +#, 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" @@ -25,6 +37,11 @@ msgstr "" 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" diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index 42fed16eb46..5e95c4c950b 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -18,6 +18,7 @@ # ############################################################################## from openerp.osv.orm import Model, fields +from openerp.tools.translate import _ class ResPartner(Model): @@ -29,6 +30,10 @@ def init(self, cursor): cursor.execute('SELECT id FROM res_partner WHERE lastname IS NOT NULL Limit 1') if not cursor.fetchone(): cursor.execute('UPDATE res_partner set lastname = name WHERE name IS NOT NULL') + # Create Sql constraint if table is not empty + cursor.execute('SELECT id FROM res_partner Limit 1') + if cursor.fetchone(): + cursor.execute('ALTER TABLE res_partner ALTER COLUMN lastname SET NOT NULL') def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): res = {} @@ -41,13 +46,39 @@ def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): return res def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None): - return self.write(cursor, uid, partner_id, - {'lastname': field_value}, context=context) + """ + # Try to reverse the effect of _compute_name_custom: + # * if is_company is True then lastname = name and firstname False + # * if firstname change in the new name: lastname is set to new name, firstname is reset + # * if only lastname change in the new name: lastname is updated accordingly, firstname remains untouched + """ + vals = {'lastname': field_value, 'firstname': False} + dict = self.read(cursor, uid, [partner_id], ['firstname', 'is_company'], context=context)[0] + if not dict['is_company']: + to_check = ' %s' % dict['firstname'] + if field_value.endswith(to_check): + vals['lastname'] = field_value[:-len(to_check)] + del(vals['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 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 vals.get('name'): corr_vals = vals.copy() diff --git a/partner_firstname/partner_view.xml b/partner_firstname/partner_view.xml index 8f0368373f3..9a88c6e805f 100644 --- a/partner_firstname/partner_view.xml +++ b/partner_firstname/partner_view.xml @@ -32,15 +32,26 @@ - + - - - - + - - - + + + - + - +
-
- -
- {'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]} -
+ + {'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]} -
diff --git a/partner_firstname/res_user_view.xml b/partner_firstname/res_user_view.xml index 56f91507c7e..f6516468d8f 100644 --- a/partner_firstname/res_user_view.xml +++ b/partner_firstname/res_user_view.xml @@ -9,17 +9,23 @@ -