← Back to team overview

savoirfairelinux-openerp team mailing list archive

lp:~savoirfairelinux-openerp/partner-contact-management/firstname_lastname_fix_bug_email into lp:~savoirfairelinux-openerp/partner-contact-management/base_contact_by_functions

 

elhadji.dem@xxxxxxxxxxxxxxxxxxxx has proposed merging lp:~savoirfairelinux-openerp/partner-contact-management/firstname_lastname_fix_bug_email into lp:~savoirfairelinux-openerp/partner-contact-management/base_contact_by_functions.

Requested reviews:
  Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter)

For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/partner-contact-management/firstname_lastname_fix_bug_email/+merge/202772

[IMP] merge with https://code.launchpad.net/~savoirfairelinux-openerp/partner-contact-management/partner_firstname_lastname.It adds base_continent module;
- replace lastname by name, add full (=firstname + name).
- remove firstname_display_name_trigger because it is redundant; 
- is_company field from contact view: this field also exists in partner view;it is redundant
- Redefine user class.
-- 
https://code.launchpad.net/~savoirfairelinux-openerp/partner-contact-management/firstname_lastname_fix_bug_email/+merge/202772
Your team Savoir-faire Linux' OpenERP is subscribed to branch lp:~savoirfairelinux-openerp/partner-contact-management/base_contact_by_functions.
=== added directory 'base_continent'
=== added file 'base_continent/__init__.py'
--- base_continent/__init__.py	1970-01-01 00:00:00 +0000
+++ base_continent/__init__.py	2014-01-22 23:37:10 +0000
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    Author: Romain Deheele
+#    Copyright 2014 Camptocamp SA
+#
+#    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 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 General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import base_continent
+from . import country
+from . import partner

=== added file 'base_continent/__openerp__.py'
--- base_continent/__openerp__.py	1970-01-01 00:00:00 +0000
+++ base_continent/__openerp__.py	2014-01-22 23:37:10 +0000
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Romain Deheele
+#    Copyright 2014 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+ 'name': 'Continent management',
+ 'version': '1.0',
+ 'depends': ['base'],
+ 'author': 'Camptocamp',
+ 'license': 'AGPL-3',
+ 'description': """
+This module introduces continent management.
+============================================
+Links continents to countries,
+adds continent field on partner form
+""",
+ 'category': 'Generic Modules/Base',
+ 'data': [
+     'base_continent_view.xml',
+     'base_continent_data.xml',
+     'security/ir.model.access.csv'],
+ 'active': False,
+ 'installable': True,
+}

=== added file 'base_continent/base_continent.py'
--- base_continent/base_continent.py	1970-01-01 00:00:00 +0000
+++ base_continent/base_continent.py	2014-01-22 23:37:10 +0000
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Romain Deheele
+#    Copyright 2014 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class Continent(Model):
+    _name = 'res.continent'
+    _description = 'Continent'
+    _columns = {
+        'name': fields.char('Continent Name', size=64,
+                            help='The full name of the continent.',
+                            required=True, translate=True),
+    }
+    _order = 'name'

=== added file 'base_continent/base_continent_data.xml'
--- base_continent/base_continent_data.xml	1970-01-01 00:00:00 +0000
+++ base_continent/base_continent_data.xml	2014-01-22 23:37:10 +0000
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data noupdate="1">
+
+        <record id="af" model="res.continent">
+            <field name="name">Africa</field>
+        </record>
+        <record id="an" model="res.continent">
+            <field name="name">Antarctica</field>
+        </record>
+        <record id="as" model="res.continent">
+            <field name="name">Asia</field>
+        </record>
+        <record id="eu" model="res.continent">
+            <field name="name">Europe</field>
+        </record>
+        <record id="na" model="res.continent">
+            <field name="name">North America</field>
+        </record>
+        <record id="oc" model="res.continent">
+            <field name="name">Oceania</field>
+        </record>
+        <record id="sa" model="res.continent">
+            <field name="name">South America</field>
+        </record>
+    </data>
+</openerp>

=== added file 'base_continent/base_continent_view.xml'
--- base_continent/base_continent_view.xml	1970-01-01 00:00:00 +0000
+++ base_continent/base_continent_view.xml	2014-01-22 23:37:10 +0000
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+        <!-- add continent to res country tree -->
+        <record model="ir.ui.view" id="view_country_tree_add_continent">
+            <field name="name">res.country.tree.add_continent</field>
+            <field name="model">res.country</field>
+            <field name="inherit_id" ref="base.view_country_tree" />
+            <field name="arch" type="xml">
+                <field name="code" position="after">
+                    <field name="continent_id"/>
+                </field>
+            </field>
+        </record>
+
+        <!-- add continent to res country form -->
+        <record model="ir.ui.view" id="view_country_form_add_continent">
+            <field name="name">res.country.form.add_continent</field>
+            <field name="model">res.country</field>
+            <field name="inherit_id" ref="base.view_country_form"/>
+            <field name="arch" type="xml">
+                <field name="code" position="after">
+                    <field name="continent_id"/>
+                </field>
+            </field>
+        </record>
+
+        <record id="view_continent_tree" model="ir.ui.view">
+            <field name="name">res.continent.tree</field>
+            <field name="model">res.continent</field>
+            <field name="arch" type="xml">
+                <tree string="Continent">
+                    <field name="name"/>
+                </tree>
+            </field>
+        </record>
+
+        <record id="view_continent_form" model="ir.ui.view">
+            <field name="name">res.continent.form</field>
+            <field name="model">res.continent</field>
+            <field name="arch" type="xml">
+                <form string="Continent" version="7.0">
+                    <group>
+                        <field name="name"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <record id="action_continent" model="ir.actions.act_window">
+            <field name="name">Continents</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">res.continent</field>
+            <field name="view_type">form</field>
+            <field name="help">Display and manage the list of all continents that can be assigned to your partner records.</field>
+        </record>
+
+        <menuitem action="action_continent" id="menu_continent_partner" parent="base.menu_localisation" sequence="1" groups="base.group_no_one"/>
+
+        <!-- add continent to res partner form -->
+        <record model="ir.ui.view" id="res_partner_form_add_continent">
+            <field name="name">res.partner.form.add_continent</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="base.view_partner_form"/>
+            <field name="arch" type="xml">
+                <field name="country_id" position="after">
+                    <field name="continent_id" widget="selection"/>
+                </field>
+            </field>
+        </record>
+
+  </data>
+</openerp>

=== added file 'base_continent/country.py'
--- base_continent/country.py	1970-01-01 00:00:00 +0000
+++ base_continent/country.py	2014-01-22 23:37:10 +0000
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Romain Deheele
+#    Copyright 2014 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class Country(Model):
+    _inherit = 'res.country'
+    _columns = {
+        'continent_id': fields.many2one('res.continent', 'Continent'),
+    }

=== added directory 'base_continent/i18n'
=== added file 'base_continent/i18n/base_continent.po'
--- base_continent/i18n/base_continent.po	1970-01-01 00:00:00 +0000
+++ base_continent/i18n/base_continent.po	2014-01-22 23:37:10 +0000
@@ -0,0 +1,56 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* base_continent
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-14 15:19+0000\n"
+"PO-Revision-Date: 2014-01-14 15:19+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: base_continent
+#: model:ir.actions.act_window,help:base_continent.action_continent
+msgid "Display and manage the list of all continents that can be assigned to your partner records."
+msgstr ""
+
+#. module: base_continent
+#: model:ir.actions.act_window,name:base_continent.action_continent
+#: model:ir.ui.menu,name:base_continent.menu_continent_partner
+msgid "Continents"
+msgstr ""
+
+#. module: base_continent
+#: model:ir.model,name:base_continent.model_res_country
+msgid "Country"
+msgstr ""
+
+#. module: base_continent
+#: help:res.continent,name:0
+msgid "The full name of the continent."
+msgstr ""
+
+#. module: base_continent
+#: field:res.continent,name:0
+msgid "Continent Name"
+msgstr ""
+
+#. module: base_continent
+#: model:ir.model,name:base_continent.model_res_partner
+msgid "Partner"
+msgstr ""
+
+#. module: base_continent
+#: model:ir.model,name:base_continent.model_res_continent
+#: view:res.continent:0
+#: field:res.country,continent_id:0
+#: field:res.partner,continent_id:0
+msgid "Continent"
+msgstr ""
+

=== added file 'base_continent/i18n/fr.po'
--- base_continent/i18n/fr.po	1970-01-01 00:00:00 +0000
+++ base_continent/i18n/fr.po	2014-01-22 23:37:10 +0000
@@ -0,0 +1,56 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* base_continent
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-14 15:19+0000\n"
+"PO-Revision-Date: 2014-01-14 15:19+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: base_continent
+#: model:ir.actions.act_window,help:base_continent.action_continent
+msgid "Display and manage the list of all continents that can be assigned to your partner records."
+msgstr "Affiche et gère la liste de tous les continents qui peuvent être associés à vos partenaires."
+
+#. module: base_continent
+#: model:ir.actions.act_window,name:base_continent.action_continent
+#: model:ir.ui.menu,name:base_continent.menu_continent_partner
+msgid "Continents"
+msgstr "Continents"
+
+#. module: base_continent
+#: model:ir.model,name:base_continent.model_res_country
+msgid "Country"
+msgstr "Pays"
+
+#. module: base_continent
+#: help:res.continent,name:0
+msgid "The full name of the continent."
+msgstr "Le nom complet du continent."
+
+#. module: base_continent
+#: field:res.continent,name:0
+msgid "Continent Name"
+msgstr "Nom du continent"
+
+#. module: base_continent
+#: model:ir.model,name:base_continent.model_res_partner
+msgid "Partner"
+msgstr "Partenaire"
+
+#. module: base_continent
+#: model:ir.model,name:base_continent.model_res_continent
+#: view:res.continent:0
+#: field:res.country,continent_id:0
+#: field:res.partner,continent_id:0
+msgid "Continent"
+msgstr "Continent"
+

=== added file 'base_continent/partner.py'
--- base_continent/partner.py	1970-01-01 00:00:00 +0000
+++ base_continent/partner.py	2014-01-22 23:37:10 +0000
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Romain Deheele
+#    Copyright 2014 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class Partner(Model):
+    _inherit = 'res.partner'
+    _columns = {
+        'continent_id': fields.related('country_id', 'continent_id',
+                                       type='many2one',
+                                       relation='res.continent',
+                                       string='Continent',
+                                       readonly=True, store=True),
+    }

=== added directory 'base_continent/security'
=== added file 'base_continent/security/ir.model.access.csv'
--- base_continent/security/ir.model.access.csv	1970-01-01 00:00:00 +0000
+++ base_continent/security/ir.model.access.csv	2014-01-22 23:37:10 +0000
@@ -0,0 +1,3 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_res_continent_group_all,res_continent group_user_all,model_res_continent,,1,0,0,0
+access_res_continent_group_user,res_continent group_user,model_res_continent,base.group_partner_manager,1,1,1,1

=== removed directory 'firstname_display_name_trigger'
=== removed file 'firstname_display_name_trigger/__init__.py'
--- firstname_display_name_trigger/__init__.py	2013-05-23 12:13:51 +0000
+++ firstname_display_name_trigger/__init__.py	1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    Author: Yannick Vaucher
-#    Copyright 2013 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 <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-import res_partner
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== removed file 'firstname_display_name_trigger/__openerp__.py'
--- firstname_display_name_trigger/__openerp__.py	2013-06-18 08:44:56 +0000
+++ firstname_display_name_trigger/__openerp__.py	1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    Author: Yannick Vaucher
-#    Copyright 2013 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 <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-{'name': 'Link module if partner_lastname and account_report_company are installed',
- 'version': '1.0',
- 'author': 'Camptocamp',
- 'maintainer': 'Camptocamp',
- 'category': 'Hidden',
- 'complexity': 'normal',  # easy, normal, expert
- 'depends': [
-     'account_report_company',
-     'partner_firstname',
-     ],
- 'description': """
-Adapt the computation of display name so that it gets visible in tree and kanban views.
- """,
- 'website': 'http://www.camptocamp.com',
- 'data': [],
- 'installable': True,
- 'images': [],
- 'auto_install': True,
- 'license': 'AGPL-3',
- 'application': False}
-

=== removed file 'firstname_display_name_trigger/res_partner.py'
--- firstname_display_name_trigger/res_partner.py	2013-12-04 12:52:48 +0000
+++ firstname_display_name_trigger/res_partner.py	1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    Author: Yannick Vaucher
-#    Copyright 2013 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 <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-from openerp.osv import orm, fields
-
-
-class ResPartner(orm.Model):
-    _inherit = 'res.partner'
-
-    def _display_name_compute(self, cr, uid, ids, name, args, context=None):
-        return dict(self.name_get(cr, uid, ids, context=context))
-
-    def name_get(self, cr, uid, ids, context=None):
-        """ By pass of name_get to use directly firstname and lastname
-        as we cannot ensure name as already been computed when calling this
-        method for display_name"""
-        if context is None:
-            context = {}
-        if isinstance(ids, (int, long)):
-            ids = [ids]
-        res = []
-        for record in self.browse(cr, uid, ids, context=context):
-            names = (record.lastname, record.firstname)
-            name = u" ".join([s for s in names if s])
-            if record.parent_id and not record.is_company:
-                name =  "%s, %s" % (record.parent_id.name, name)
-            if context.get('show_address'):
-                name = name + "\n" + self._display_address(cr, uid, record, without_company=True, context=context)
-                name = name.replace('\n\n','\n')
-                name = name.replace('\n\n','\n')
-            if context.get('show_email') and record.email:
-                name = "%s <%s>" % (name, record.email)
-            res.append((record.id, name))
-        return res
-
-
-    _display_name_store_triggers = {
-        'res.partner': (lambda self,cr,uid,ids,context=None: self.search(cr, uid, [('id','child_of',ids)]),
-                        ['parent_id', 'is_company', 'name', 'firstname', 'lastname'], 10)
-        }
-
-    # indirection to avoid passing a copy of the overridable method when declaring the function field
-    _display_name = lambda self, *args, **kwargs: self._display_name_compute(*args, **kwargs)
-
-    _columns = {
-        # extra field to allow ORDER BY to match visible names
-        'display_name': fields.function(_display_name, type='char', string='Name', store=_display_name_store_triggers),
-        }

=== removed directory 'firstname_display_name_trigger/tests'
=== removed file 'firstname_display_name_trigger/tests/__init__.py'
--- firstname_display_name_trigger/tests/__init__.py	2013-05-24 11:39:16 +0000
+++ firstname_display_name_trigger/tests/__init__.py	1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-import test_display_name
-
-checks = [
-    test_display_name
-    ]

=== removed file 'firstname_display_name_trigger/tests/test_display_name.py'
--- firstname_display_name_trigger/tests/test_display_name.py	2013-05-24 11:39:16 +0000
+++ firstname_display_name_trigger/tests/test_display_name.py	1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
-import unittest2
-
-import openerp.tests.common as common
-
-class test_display_name(common.TransactionCase):
-
-    def setUp(self):
-        super(test_display_name,self).setUp()
-        cr, uid = self.cr, self.uid
-        self.res_partner = self.registry('res.partner')
-
-
-    def test_00_create_res_partner(self):
-        """ Test if the display name has been correctly set """
-        cr, uid = self.cr, self.uid
-        partner_id = self.res_partner.create(cr, uid, {'lastname': 'Lastname', 'firstname': 'Firstname', 'is_company': True})
-        partner_records = self.res_partner.browse(cr, uid, [partner_id])
-        p1 = partner_records[0]
-        self.assertEqual(p1.display_name, 'Lastname Firstname', 'Partner display_name incorect')
-
-    def test_01_res_partner_write_lastname(self):
-        """ Test if the display name has been correctly set """
-        cr, uid = self.cr, self.uid
-        partner_id = self.res_partner.create(cr, uid, {'lastname': 'Lastname', 'firstname': 'Firstname', 'is_company': True})
-        partner_records = self.res_partner.browse(cr, uid, [partner_id])
-        p1 = partner_records[0]
-        self.res_partner.write(cr, uid, partner_id, {'lastname': 'Last'})
-        self.assertEqual(p1.display_name, 'Last Firstname', 'Partner display_name incorect')
-
-if __name__ == '__main__':
-    unittest2.main()

=== modified file 'partner_firstname/__openerp__.py'
--- partner_firstname/__openerp__.py	2014-01-03 15:07:50 +0000
+++ partner_firstname/__openerp__.py	2014-01-22 23:37:10 +0000
@@ -18,23 +18,33 @@
 #
 ##############################################################################
 
-{'name': 'Partner first name, last name',
- 'description':  """Split first name and last name on res.partner.
+{
+    'name': 'Partner first name, last name',
+    'description': """
+Split first name and last name on res.partner.
+==============================================
 
 The field 'name' becomes a stored function field concatenating lastname, firstname
+
+Contributeurs
+-------------
+* El Hadji Dem (elhadji.dem@xxxxxxxxxxxxxxxxxxxx)
+* Camptocamp
 """,
- 'version': '1.0.1',
- 'author': 'Camptocamp',
- 'category': 'MISC',
- 'website': 'http://www.camptocamp.com',
- 'depends': ['base'],
- 'data': [
-     'partner_view.xml',
-     'res_user_view.xml',
- ],
- 'demo': [],
- 'test': [],
- 'auto_install': False,
- 'installable': True,
- 'images': []
+    'version': '1.0.1',
+    'author': 'Camptocamp',
+    'category': 'MISC',
+    'website': 'http://www.camptocamp.com',
+    'depends': ['base'],
+    'data': [
+        'partner_view.xml',
+        'res_user_view.xml',
+    ],
+    'demo': [],
+    'test': [],
+    'auto_install': False,
+    'installable': True,
+    'images': []
 }
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'partner_firstname/partner.py'
--- partner_firstname/partner.py	2013-08-12 06:18:39 +0000
+++ partner_firstname/partner.py	2014-01-22 23:37:10 +0000
@@ -17,49 +17,68 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-from openerp.osv.orm import Model, fields
-
-
-class ResPartner(Model):
+
+from openerp.osv import orm, fields
+
+
+class res_partner(orm.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 _display_name_compute(self, cr, uid, ids, name, args, context=None):
+        return dict(self.name_get(cr, uid, ids, context=context))
 
-    def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None):
-        res = {}
-        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
+    def name_get(self, cr, uid, ids, context=None):
+        """ By pass of name_get to use directly firstname and lastname
+        as we cannot ensure name as already been computed when calling this
+        method for display_name"""
+        if context is None:
+            context = {}
+        if isinstance(ids, (int, long)):
+            ids = [ids]
+        res = []
+        for record in self.browse(cr, uid, ids, context=context):
+            names = (record.firstname, record.name)
+            name = u" ".join([s for s in names if s])
+            if record.parent_id and not record.is_company:
+                name = "%s, %s" % (record.parent_id.name, name)
+            if context.get('show_address'):
+                name = name + "\n" + self._display_address(cr, uid, record, without_company=True, context=context)
+                name = name.replace('\n\n', '\n')
+                name = name.replace('\n\n', '\n')
+            if context.get('show_email') and record.email:
+                name = "%s <%s>" % (name, record.email)
+            res.append((record.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}, 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 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,
-                                        fnct_inv=_write_name),
-
-                'firstname': fields.char("Firstname"),
-                'lastname': fields.char("Lastname", required=True)}
+    def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
+        if args is None:
+            args = []
+        if context is None:
+            context = {}
+        if name:
+            ids = self.search(cr, uid, [('full_name', operator, name)] + args, limit=limit, context=context)
+        else:
+            ids = self.search(cr, uid, args, limit=limit, context=context or {})
+        return self.name_get(cr, uid, ids, context=context)
+
+    def get_full_name(self, cr, uid, ids, field_name, arg, context=None):
+        return dict(self.name_get(cr, uid, ids, context=context))
+
+    _display_name_store_triggers = {
+        'res.partner': (lambda self, cr, uid, ids, context=None: self.search(cr, uid, [('id', 'child_of', ids)]),
+                        ['parent_id', 'is_company', 'name', 'firstname'], 10)
+    }
+
+    # indirection to avoid passing a copy of the overridable method when declaring the function field
+    _display_name = lambda self, *args, **kwargs: self._display_name_compute(*args, **kwargs)
+
+    _columns = {
+        'full_name': fields.function(_display_name, type='char',
+                                     string='Full name',
+                                     store=_display_name_store_triggers,
+                                     help="First name."),
+        'firstname': fields.char("First name", help="First name.")
+    }
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'partner_firstname/partner_view.xml'
--- partner_firstname/partner_view.xml	2013-11-13 16:18:13 +0000
+++ partner_firstname/partner_view.xml	2014-01-22 23:37:10 +0000
@@ -1,51 +1,54 @@
 <openerp>
   <data>
-    <record id="view_partner_simple_form_firstname" model="ir.ui.view">
-      <field name="name">res.partner.simplified.form.firstname</field>
-      <field name="model">res.partner</field>
-      <field name="inherit_id" ref="base.view_partner_simple_form"/>
-      <field name="arch" type="xml">
-        <field name="name" position="attributes">
-            <attribute name="attrs">{'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]}</attribute>
-        </field>
-        <field name="category_id" position="before">
-          <group attrs="{'invisible': [('is_company', '=', True)]}">
-              <field name="lastname" attrs="{'required': [('is_company', '=', False)]}"/>
-            <field name="firstname" />
-          </group>
-        </field>
-      </field>
-    </record>
 
     <record id="view_partner_form_firstname" model="ir.ui.view">
       <field name="name">res.partner.form.firstname</field>
       <field name="model">res.partner</field>
       <field name="inherit_id" ref="base.view_partner_form"/>
       <field name="arch" type="xml">
-        <field name="name" position="attributes">
-            <attribute name="attrs">{'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]}</attribute>
-        </field>
+        <field name="name" position="replace"/>
         <field name="category_id" position="before">
           <group attrs="{'invisible': [('is_company', '=', True)]}">
-            <field name="lastname" attrs="{'required': [('is_company', '=', False)]}"/>
-            <field name="firstname"/>
+            <field name="firstname" attrs="{'required': [('is_company', '=', False)]}"/>
+          </group>
+          <group>
+            <field name="name" position="attributes">
+              <attribute name="attrs">{'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]}</attribute>
+            </field>
           </group>
         </field>
-        <!-- Add firstname and last name in inner contact form of child_ids -->
-        <xpath expr="//form[@string='Contact']/sheet/div" position="after">
-           <group attrs="{'invisible': [('is_company', '=', True)]}">
-            <field name="lastname" attrs="{'required': [('is_company', '=', False)]}"/>
+
+        <!-- Add first name and name in inner contact form of child_ids -->
+        <xpath expr="//form[@string='Contact']/sheet/div/h1/field[@name='name']" position="replace"/>
+        <xpath expr="//form[@string='Contact']/sheet/div/label" position="after">
+          <group>
             <field name="firstname"/>
-           </group> 
-        </xpath>
-        <xpath expr="//form[@string='Contact']/sheet/div/h1" position="after">
-           <field name="is_company" on_change="onchange_type(is_company)" class="oe_inline"/>
-           <label for="is_company" string="Is a Company?"/>)
-        </xpath>
-
-
+            <field name="name"/>
+          </group>
+        </xpath>
+
+        <label for="name" position="attributes">
+          <attribute name="invisible">1</attribute>
+        </label>
+        <!-- Add first name and name in inner contact kanban view -->
+        <xpath expr="//t[@t-name='kanban-box']//div[@class='oe_module_desc']//field[@name='name']" position="replace">
+          <field name="firstname"/>
+          <field name="name"/>
+        </xpath>
       </field>
     </record>
+    <!-- Search view with full name-->
+    <record id="view_res_partner_filter_firstname" model="ir.ui.view">
+            <field name="name">res.partner.select</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="base.view_res_partner_filter"/>
+            <field name="arch" type="xml">
+                   <field name="name" position="replace">
+                     <field name="name"
+                       filter_domain="['|','|',('full_name','ilike',self),('parent_id','ilike',self),('ref','=',self)]"/>
+                   </field>
+            </field>
+        </record>
 
   </data>
 </openerp>

=== modified file 'partner_firstname/res_user.py'
--- partner_firstname/res_user.py	2013-02-20 14:00:17 +0000
+++ partner_firstname/res_user.py	2014-01-22 23:37:10 +0000
@@ -17,10 +17,11 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-from openerp.osv import orm
-
-
-class ResUsers(orm.Model):
+
+from openerp.osv import orm, fields
+
+
+class res_user(orm.Model):
     """Allows user creation from user form as
     name is not in form"""
 
@@ -29,4 +30,4 @@
     def create(self, cursor, uid, vals, context=None):
         if not vals.get('name'):
             vals['name'] = vals['login']
-        return super(ResUsers, self).create(cursor, uid, vals, context=context)
+        return super(res_user, self).create(cursor, uid, vals, context=context)


Follow ups