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

Status: Merged
Merged at revision: 36
Proposed branch: lp:~savoirfairelinux-openerp/partner-contact-management/firstname_lastname_fix_bug_email
Merge into: lp:~savoirfairelinux-openerp/partner-contact-management/base_contact_by_functions
Diff against target: 908 lines (+505/-259)
19 files modified
base_continent/__init__.py (+24/-0)
base_continent/__openerp__.py (+42/-0)
base_continent/base_continent.py (+34/-0)
base_continent/base_continent_data.xml (+27/-0)
base_continent/base_continent_view.xml (+73/-0)
base_continent/country.py (+30/-0)
base_continent/i18n/base_continent.po (+56/-0)
base_continent/i18n/fr.po (+56/-0)
base_continent/partner.py (+34/-0)
base_continent/security/ir.model.access.csv (+3/-0)
firstname_display_name_trigger/__init__.py (+0/-24)
firstname_display_name_trigger/__openerp__.py (+0/-41)
firstname_display_name_trigger/res_partner.py (+0/-65)
firstname_display_name_trigger/tests/__init__.py (+0/-5)
firstname_display_name_trigger/tests/test_display_name.py (+0/-31)
partner_firstname/__openerp__.py (+26/-16)
partner_firstname/partner.py (+58/-39)
partner_firstname/partner_view.xml (+36/-33)
partner_firstname/res_user.py (+6/-5)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/partner-contact-management/firstname_lastname_fix_bug_email
Reviewer Review Type Date Requested Status
Sandy Carter (http://www.savoirfairelinux.com) Pending
Review via email: mp+202772@code.launchpad.net

Description of the change

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

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'base_continent'
2=== added file 'base_continent/__init__.py'
3--- base_continent/__init__.py 1970-01-01 00:00:00 +0000
4+++ base_continent/__init__.py 2014-01-22 23:37:10 +0000
5@@ -0,0 +1,24 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# Author: Romain Deheele
10+# Copyright 2014 Camptocamp SA
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU General Public License as published by
14+# the Free Software Foundation, either version 3 of the License, or
15+# (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU General Public License for more details.
21+#
22+# You should have received a copy of the GNU General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+from . import base_continent
28+from . import country
29+from . import partner
30
31=== added file 'base_continent/__openerp__.py'
32--- base_continent/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ base_continent/__openerp__.py 2014-01-22 23:37:10 +0000
34@@ -0,0 +1,42 @@
35+# -*- coding: utf-8 -*-
36+##############################################################################
37+#
38+# Author: Romain Deheele
39+# Copyright 2014 Camptocamp SA
40+#
41+# This program is free software: you can redistribute it and/or modify
42+# it under the terms of the GNU Affero General Public License as
43+# published by the Free Software Foundation, either version 3 of the
44+# License, or (at your option) any later version.
45+#
46+# This program is distributed in the hope that it will be useful,
47+# but WITHOUT ANY WARRANTY; without even the implied warranty of
48+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+# GNU Affero General Public License for more details.
50+#
51+# You should have received a copy of the GNU Affero General Public License
52+# along with this program. If not, see <http://www.gnu.org/licenses/>.
53+#
54+##############################################################################
55+
56+
57+{
58+ 'name': 'Continent management',
59+ 'version': '1.0',
60+ 'depends': ['base'],
61+ 'author': 'Camptocamp',
62+ 'license': 'AGPL-3',
63+ 'description': """
64+This module introduces continent management.
65+============================================
66+Links continents to countries,
67+adds continent field on partner form
68+""",
69+ 'category': 'Generic Modules/Base',
70+ 'data': [
71+ 'base_continent_view.xml',
72+ 'base_continent_data.xml',
73+ 'security/ir.model.access.csv'],
74+ 'active': False,
75+ 'installable': True,
76+}
77
78=== added file 'base_continent/base_continent.py'
79--- base_continent/base_continent.py 1970-01-01 00:00:00 +0000
80+++ base_continent/base_continent.py 2014-01-22 23:37:10 +0000
81@@ -0,0 +1,34 @@
82+# -*- coding: utf-8 -*-
83+##############################################################################
84+#
85+# Author: Romain Deheele
86+# Copyright 2014 Camptocamp SA
87+#
88+# This program is free software: you can redistribute it and/or modify
89+# it under the terms of the GNU Affero General Public License as
90+# published by the Free Software Foundation, either version 3 of the
91+# License, or (at your option) any later version.
92+#
93+# This program is distributed in the hope that it will be useful,
94+# but WITHOUT ANY WARRANTY; without even the implied warranty of
95+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+# GNU Affero General Public License for more details.
97+#
98+# You should have received a copy of the GNU Affero General Public License
99+# along with this program. If not, see <http://www.gnu.org/licenses/>.
100+#
101+##############################################################################
102+
103+from openerp.osv.orm import Model
104+from openerp.osv import fields
105+
106+
107+class Continent(Model):
108+ _name = 'res.continent'
109+ _description = 'Continent'
110+ _columns = {
111+ 'name': fields.char('Continent Name', size=64,
112+ help='The full name of the continent.',
113+ required=True, translate=True),
114+ }
115+ _order = 'name'
116
117=== added file 'base_continent/base_continent_data.xml'
118--- base_continent/base_continent_data.xml 1970-01-01 00:00:00 +0000
119+++ base_continent/base_continent_data.xml 2014-01-22 23:37:10 +0000
120@@ -0,0 +1,27 @@
121+<?xml version="1.0" encoding="utf-8"?>
122+<openerp>
123+ <data noupdate="1">
124+
125+ <record id="af" model="res.continent">
126+ <field name="name">Africa</field>
127+ </record>
128+ <record id="an" model="res.continent">
129+ <field name="name">Antarctica</field>
130+ </record>
131+ <record id="as" model="res.continent">
132+ <field name="name">Asia</field>
133+ </record>
134+ <record id="eu" model="res.continent">
135+ <field name="name">Europe</field>
136+ </record>
137+ <record id="na" model="res.continent">
138+ <field name="name">North America</field>
139+ </record>
140+ <record id="oc" model="res.continent">
141+ <field name="name">Oceania</field>
142+ </record>
143+ <record id="sa" model="res.continent">
144+ <field name="name">South America</field>
145+ </record>
146+ </data>
147+</openerp>
148
149=== added file 'base_continent/base_continent_view.xml'
150--- base_continent/base_continent_view.xml 1970-01-01 00:00:00 +0000
151+++ base_continent/base_continent_view.xml 2014-01-22 23:37:10 +0000
152@@ -0,0 +1,73 @@
153+<?xml version="1.0" encoding="utf-8"?>
154+<openerp>
155+ <data>
156+ <!-- add continent to res country tree -->
157+ <record model="ir.ui.view" id="view_country_tree_add_continent">
158+ <field name="name">res.country.tree.add_continent</field>
159+ <field name="model">res.country</field>
160+ <field name="inherit_id" ref="base.view_country_tree" />
161+ <field name="arch" type="xml">
162+ <field name="code" position="after">
163+ <field name="continent_id"/>
164+ </field>
165+ </field>
166+ </record>
167+
168+ <!-- add continent to res country form -->
169+ <record model="ir.ui.view" id="view_country_form_add_continent">
170+ <field name="name">res.country.form.add_continent</field>
171+ <field name="model">res.country</field>
172+ <field name="inherit_id" ref="base.view_country_form"/>
173+ <field name="arch" type="xml">
174+ <field name="code" position="after">
175+ <field name="continent_id"/>
176+ </field>
177+ </field>
178+ </record>
179+
180+ <record id="view_continent_tree" model="ir.ui.view">
181+ <field name="name">res.continent.tree</field>
182+ <field name="model">res.continent</field>
183+ <field name="arch" type="xml">
184+ <tree string="Continent">
185+ <field name="name"/>
186+ </tree>
187+ </field>
188+ </record>
189+
190+ <record id="view_continent_form" model="ir.ui.view">
191+ <field name="name">res.continent.form</field>
192+ <field name="model">res.continent</field>
193+ <field name="arch" type="xml">
194+ <form string="Continent" version="7.0">
195+ <group>
196+ <field name="name"/>
197+ </group>
198+ </form>
199+ </field>
200+ </record>
201+
202+ <record id="action_continent" model="ir.actions.act_window">
203+ <field name="name">Continents</field>
204+ <field name="type">ir.actions.act_window</field>
205+ <field name="res_model">res.continent</field>
206+ <field name="view_type">form</field>
207+ <field name="help">Display and manage the list of all continents that can be assigned to your partner records.</field>
208+ </record>
209+
210+ <menuitem action="action_continent" id="menu_continent_partner" parent="base.menu_localisation" sequence="1" groups="base.group_no_one"/>
211+
212+ <!-- add continent to res partner form -->
213+ <record model="ir.ui.view" id="res_partner_form_add_continent">
214+ <field name="name">res.partner.form.add_continent</field>
215+ <field name="model">res.partner</field>
216+ <field name="inherit_id" ref="base.view_partner_form"/>
217+ <field name="arch" type="xml">
218+ <field name="country_id" position="after">
219+ <field name="continent_id" widget="selection"/>
220+ </field>
221+ </field>
222+ </record>
223+
224+ </data>
225+</openerp>
226
227=== added file 'base_continent/country.py'
228--- base_continent/country.py 1970-01-01 00:00:00 +0000
229+++ base_continent/country.py 2014-01-22 23:37:10 +0000
230@@ -0,0 +1,30 @@
231+# -*- coding: utf-8 -*-
232+##############################################################################
233+#
234+# Author: Romain Deheele
235+# Copyright 2014 Camptocamp SA
236+#
237+# This program is free software: you can redistribute it and/or modify
238+# it under the terms of the GNU Affero General Public License as
239+# published by the Free Software Foundation, either version 3 of the
240+# License, or (at your option) any later version.
241+#
242+# This program is distributed in the hope that it will be useful,
243+# but WITHOUT ANY WARRANTY; without even the implied warranty of
244+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
245+# GNU Affero General Public License for more details.
246+#
247+# You should have received a copy of the GNU Affero General Public License
248+# along with this program. If not, see <http://www.gnu.org/licenses/>.
249+#
250+##############################################################################
251+
252+from openerp.osv.orm import Model
253+from openerp.osv import fields
254+
255+
256+class Country(Model):
257+ _inherit = 'res.country'
258+ _columns = {
259+ 'continent_id': fields.many2one('res.continent', 'Continent'),
260+ }
261
262=== added directory 'base_continent/i18n'
263=== added file 'base_continent/i18n/base_continent.po'
264--- base_continent/i18n/base_continent.po 1970-01-01 00:00:00 +0000
265+++ base_continent/i18n/base_continent.po 2014-01-22 23:37:10 +0000
266@@ -0,0 +1,56 @@
267+# Translation of OpenERP Server.
268+# This file contains the translation of the following modules:
269+# * base_continent
270+#
271+msgid ""
272+msgstr ""
273+"Project-Id-Version: OpenERP Server 7.0\n"
274+"Report-Msgid-Bugs-To: \n"
275+"POT-Creation-Date: 2014-01-14 15:19+0000\n"
276+"PO-Revision-Date: 2014-01-14 15:19+0000\n"
277+"Last-Translator: <>\n"
278+"Language-Team: \n"
279+"MIME-Version: 1.0\n"
280+"Content-Type: text/plain; charset=UTF-8\n"
281+"Content-Transfer-Encoding: \n"
282+"Plural-Forms: \n"
283+
284+#. module: base_continent
285+#: model:ir.actions.act_window,help:base_continent.action_continent
286+msgid "Display and manage the list of all continents that can be assigned to your partner records."
287+msgstr ""
288+
289+#. module: base_continent
290+#: model:ir.actions.act_window,name:base_continent.action_continent
291+#: model:ir.ui.menu,name:base_continent.menu_continent_partner
292+msgid "Continents"
293+msgstr ""
294+
295+#. module: base_continent
296+#: model:ir.model,name:base_continent.model_res_country
297+msgid "Country"
298+msgstr ""
299+
300+#. module: base_continent
301+#: help:res.continent,name:0
302+msgid "The full name of the continent."
303+msgstr ""
304+
305+#. module: base_continent
306+#: field:res.continent,name:0
307+msgid "Continent Name"
308+msgstr ""
309+
310+#. module: base_continent
311+#: model:ir.model,name:base_continent.model_res_partner
312+msgid "Partner"
313+msgstr ""
314+
315+#. module: base_continent
316+#: model:ir.model,name:base_continent.model_res_continent
317+#: view:res.continent:0
318+#: field:res.country,continent_id:0
319+#: field:res.partner,continent_id:0
320+msgid "Continent"
321+msgstr ""
322+
323
324=== added file 'base_continent/i18n/fr.po'
325--- base_continent/i18n/fr.po 1970-01-01 00:00:00 +0000
326+++ base_continent/i18n/fr.po 2014-01-22 23:37:10 +0000
327@@ -0,0 +1,56 @@
328+# Translation of OpenERP Server.
329+# This file contains the translation of the following modules:
330+# * base_continent
331+#
332+msgid ""
333+msgstr ""
334+"Project-Id-Version: OpenERP Server 7.0\n"
335+"Report-Msgid-Bugs-To: \n"
336+"POT-Creation-Date: 2014-01-14 15:19+0000\n"
337+"PO-Revision-Date: 2014-01-14 15:19+0000\n"
338+"Last-Translator: <>\n"
339+"Language-Team: \n"
340+"MIME-Version: 1.0\n"
341+"Content-Type: text/plain; charset=UTF-8\n"
342+"Content-Transfer-Encoding: \n"
343+"Plural-Forms: \n"
344+
345+#. module: base_continent
346+#: model:ir.actions.act_window,help:base_continent.action_continent
347+msgid "Display and manage the list of all continents that can be assigned to your partner records."
348+msgstr "Affiche et gère la liste de tous les continents qui peuvent être associés à vos partenaires."
349+
350+#. module: base_continent
351+#: model:ir.actions.act_window,name:base_continent.action_continent
352+#: model:ir.ui.menu,name:base_continent.menu_continent_partner
353+msgid "Continents"
354+msgstr "Continents"
355+
356+#. module: base_continent
357+#: model:ir.model,name:base_continent.model_res_country
358+msgid "Country"
359+msgstr "Pays"
360+
361+#. module: base_continent
362+#: help:res.continent,name:0
363+msgid "The full name of the continent."
364+msgstr "Le nom complet du continent."
365+
366+#. module: base_continent
367+#: field:res.continent,name:0
368+msgid "Continent Name"
369+msgstr "Nom du continent"
370+
371+#. module: base_continent
372+#: model:ir.model,name:base_continent.model_res_partner
373+msgid "Partner"
374+msgstr "Partenaire"
375+
376+#. module: base_continent
377+#: model:ir.model,name:base_continent.model_res_continent
378+#: view:res.continent:0
379+#: field:res.country,continent_id:0
380+#: field:res.partner,continent_id:0
381+msgid "Continent"
382+msgstr "Continent"
383+
384
385=== added file 'base_continent/partner.py'
386--- base_continent/partner.py 1970-01-01 00:00:00 +0000
387+++ base_continent/partner.py 2014-01-22 23:37:10 +0000
388@@ -0,0 +1,34 @@
389+# -*- coding: utf-8 -*-
390+##############################################################################
391+#
392+# Author: Romain Deheele
393+# Copyright 2014 Camptocamp SA
394+#
395+# This program is free software: you can redistribute it and/or modify
396+# it under the terms of the GNU Affero General Public License as
397+# published by the Free Software Foundation, either version 3 of the
398+# License, or (at your option) any later version.
399+#
400+# This program is distributed in the hope that it will be useful,
401+# but WITHOUT ANY WARRANTY; without even the implied warranty of
402+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
403+# GNU Affero General Public License for more details.
404+#
405+# You should have received a copy of the GNU Affero General Public License
406+# along with this program. If not, see <http://www.gnu.org/licenses/>.
407+#
408+##############################################################################
409+
410+from openerp.osv.orm import Model
411+from openerp.osv import fields
412+
413+
414+class Partner(Model):
415+ _inherit = 'res.partner'
416+ _columns = {
417+ 'continent_id': fields.related('country_id', 'continent_id',
418+ type='many2one',
419+ relation='res.continent',
420+ string='Continent',
421+ readonly=True, store=True),
422+ }
423
424=== added directory 'base_continent/security'
425=== added file 'base_continent/security/ir.model.access.csv'
426--- base_continent/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
427+++ base_continent/security/ir.model.access.csv 2014-01-22 23:37:10 +0000
428@@ -0,0 +1,3 @@
429+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
430+access_res_continent_group_all,res_continent group_user_all,model_res_continent,,1,0,0,0
431+access_res_continent_group_user,res_continent group_user,model_res_continent,base.group_partner_manager,1,1,1,1
432
433=== removed directory 'firstname_display_name_trigger'
434=== removed file 'firstname_display_name_trigger/__init__.py'
435--- firstname_display_name_trigger/__init__.py 2013-05-23 12:13:51 +0000
436+++ firstname_display_name_trigger/__init__.py 1970-01-01 00:00:00 +0000
437@@ -1,24 +0,0 @@
438-# -*- coding: utf-8 -*-
439-##############################################################################
440-#
441-# Author: Yannick Vaucher
442-# Copyright 2013 Camptocamp SA
443-#
444-# This program is free software: you can redistribute it and/or modify
445-# it under the terms of the GNU Affero General Public License as
446-# published by the Free Software Foundation, either version 3 of the
447-# License, or (at your option) any later version.
448-#
449-# This program is distributed in the hope that it will be useful,
450-# but WITHOUT ANY WARRANTY; without even the implied warranty of
451-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
452-# GNU Affero General Public License for more details.
453-#
454-# You should have received a copy of the GNU Affero General Public License
455-# along with this program. If not, see <http://www.gnu.org/licenses/>.
456-#
457-##############################################################################
458-
459-import res_partner
460-
461-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
462
463=== removed file 'firstname_display_name_trigger/__openerp__.py'
464--- firstname_display_name_trigger/__openerp__.py 2013-06-18 08:44:56 +0000
465+++ firstname_display_name_trigger/__openerp__.py 1970-01-01 00:00:00 +0000
466@@ -1,41 +0,0 @@
467-# -*- coding: utf-8 -*-
468-##############################################################################
469-#
470-# Author: Yannick Vaucher
471-# Copyright 2013 Camptocamp SA
472-#
473-# This program is free software: you can redistribute it and/or modify
474-# it under the terms of the GNU Affero General Public License as
475-# published by the Free Software Foundation, either version 3 of the
476-# License, or (at your option) any later version.
477-#
478-# This program is distributed in the hope that it will be useful,
479-# but WITHOUT ANY WARRANTY; without even the implied warranty of
480-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
481-# GNU Affero General Public License for more details.
482-#
483-# You should have received a copy of the GNU Affero General Public License
484-# along with this program. If not, see <http://www.gnu.org/licenses/>.
485-#
486-##############################################################################
487-{'name': 'Link module if partner_lastname and account_report_company are installed',
488- 'version': '1.0',
489- 'author': 'Camptocamp',
490- 'maintainer': 'Camptocamp',
491- 'category': 'Hidden',
492- 'complexity': 'normal', # easy, normal, expert
493- 'depends': [
494- 'account_report_company',
495- 'partner_firstname',
496- ],
497- 'description': """
498-Adapt the computation of display name so that it gets visible in tree and kanban views.
499- """,
500- 'website': 'http://www.camptocamp.com',
501- 'data': [],
502- 'installable': True,
503- 'images': [],
504- 'auto_install': True,
505- 'license': 'AGPL-3',
506- 'application': False}
507-
508
509=== removed file 'firstname_display_name_trigger/res_partner.py'
510--- firstname_display_name_trigger/res_partner.py 2013-12-04 12:52:48 +0000
511+++ firstname_display_name_trigger/res_partner.py 1970-01-01 00:00:00 +0000
512@@ -1,65 +0,0 @@
513-# -*- coding: utf-8 -*-
514-##############################################################################
515-#
516-# Author: Yannick Vaucher
517-# Copyright 2013 Camptocamp SA
518-#
519-# This program is free software: you can redistribute it and/or modify
520-# it under the terms of the GNU Affero General Public License as
521-# published by the Free Software Foundation, either version 3 of the
522-# License, or (at your option) any later version.
523-#
524-# This program is distributed in the hope that it will be useful,
525-# but WITHOUT ANY WARRANTY; without even the implied warranty of
526-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
527-# GNU Affero General Public License for more details.
528-#
529-# You should have received a copy of the GNU Affero General Public License
530-# along with this program. If not, see <http://www.gnu.org/licenses/>.
531-#
532-##############################################################################
533-from openerp.osv import orm, fields
534-
535-
536-class ResPartner(orm.Model):
537- _inherit = 'res.partner'
538-
539- def _display_name_compute(self, cr, uid, ids, name, args, context=None):
540- return dict(self.name_get(cr, uid, ids, context=context))
541-
542- def name_get(self, cr, uid, ids, context=None):
543- """ By pass of name_get to use directly firstname and lastname
544- as we cannot ensure name as already been computed when calling this
545- method for display_name"""
546- if context is None:
547- context = {}
548- if isinstance(ids, (int, long)):
549- ids = [ids]
550- res = []
551- for record in self.browse(cr, uid, ids, context=context):
552- names = (record.lastname, record.firstname)
553- name = u" ".join([s for s in names if s])
554- if record.parent_id and not record.is_company:
555- name = "%s, %s" % (record.parent_id.name, name)
556- if context.get('show_address'):
557- name = name + "\n" + self._display_address(cr, uid, record, without_company=True, context=context)
558- name = name.replace('\n\n','\n')
559- name = name.replace('\n\n','\n')
560- if context.get('show_email') and record.email:
561- name = "%s <%s>" % (name, record.email)
562- res.append((record.id, name))
563- return res
564-
565-
566- _display_name_store_triggers = {
567- 'res.partner': (lambda self,cr,uid,ids,context=None: self.search(cr, uid, [('id','child_of',ids)]),
568- ['parent_id', 'is_company', 'name', 'firstname', 'lastname'], 10)
569- }
570-
571- # indirection to avoid passing a copy of the overridable method when declaring the function field
572- _display_name = lambda self, *args, **kwargs: self._display_name_compute(*args, **kwargs)
573-
574- _columns = {
575- # extra field to allow ORDER BY to match visible names
576- 'display_name': fields.function(_display_name, type='char', string='Name', store=_display_name_store_triggers),
577- }
578
579=== removed directory 'firstname_display_name_trigger/tests'
580=== removed file 'firstname_display_name_trigger/tests/__init__.py'
581--- firstname_display_name_trigger/tests/__init__.py 2013-05-24 11:39:16 +0000
582+++ firstname_display_name_trigger/tests/__init__.py 1970-01-01 00:00:00 +0000
583@@ -1,5 +0,0 @@
584-import test_display_name
585-
586-checks = [
587- test_display_name
588- ]
589
590=== removed file 'firstname_display_name_trigger/tests/test_display_name.py'
591--- firstname_display_name_trigger/tests/test_display_name.py 2013-05-24 11:39:16 +0000
592+++ firstname_display_name_trigger/tests/test_display_name.py 1970-01-01 00:00:00 +0000
593@@ -1,31 +0,0 @@
594-import unittest2
595-
596-import openerp.tests.common as common
597-
598-class test_display_name(common.TransactionCase):
599-
600- def setUp(self):
601- super(test_display_name,self).setUp()
602- cr, uid = self.cr, self.uid
603- self.res_partner = self.registry('res.partner')
604-
605-
606- def test_00_create_res_partner(self):
607- """ Test if the display name has been correctly set """
608- cr, uid = self.cr, self.uid
609- partner_id = self.res_partner.create(cr, uid, {'lastname': 'Lastname', 'firstname': 'Firstname', 'is_company': True})
610- partner_records = self.res_partner.browse(cr, uid, [partner_id])
611- p1 = partner_records[0]
612- self.assertEqual(p1.display_name, 'Lastname Firstname', 'Partner display_name incorect')
613-
614- def test_01_res_partner_write_lastname(self):
615- """ Test if the display name has been correctly set """
616- cr, uid = self.cr, self.uid
617- partner_id = self.res_partner.create(cr, uid, {'lastname': 'Lastname', 'firstname': 'Firstname', 'is_company': True})
618- partner_records = self.res_partner.browse(cr, uid, [partner_id])
619- p1 = partner_records[0]
620- self.res_partner.write(cr, uid, partner_id, {'lastname': 'Last'})
621- self.assertEqual(p1.display_name, 'Last Firstname', 'Partner display_name incorect')
622-
623-if __name__ == '__main__':
624- unittest2.main()
625
626=== modified file 'partner_firstname/__openerp__.py'
627--- partner_firstname/__openerp__.py 2014-01-03 15:07:50 +0000
628+++ partner_firstname/__openerp__.py 2014-01-22 23:37:10 +0000
629@@ -18,23 +18,33 @@
630 #
631 ##############################################################################
632
633-{'name': 'Partner first name, last name',
634- 'description': """Split first name and last name on res.partner.
635+{
636+ 'name': 'Partner first name, last name',
637+ 'description': """
638+Split first name and last name on res.partner.
639+==============================================
640
641 The field 'name' becomes a stored function field concatenating lastname, firstname
642+
643+Contributeurs
644+-------------
645+* El Hadji Dem (elhadji.dem@savoirfairelinux.com)
646+* Camptocamp
647 """,
648- 'version': '1.0.1',
649- 'author': 'Camptocamp',
650- 'category': 'MISC',
651- 'website': 'http://www.camptocamp.com',
652- 'depends': ['base'],
653- 'data': [
654- 'partner_view.xml',
655- 'res_user_view.xml',
656- ],
657- 'demo': [],
658- 'test': [],
659- 'auto_install': False,
660- 'installable': True,
661- 'images': []
662+ 'version': '1.0.1',
663+ 'author': 'Camptocamp',
664+ 'category': 'MISC',
665+ 'website': 'http://www.camptocamp.com',
666+ 'depends': ['base'],
667+ 'data': [
668+ 'partner_view.xml',
669+ 'res_user_view.xml',
670+ ],
671+ 'demo': [],
672+ 'test': [],
673+ 'auto_install': False,
674+ 'installable': True,
675+ 'images': []
676 }
677+
678+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
679
680=== modified file 'partner_firstname/partner.py'
681--- partner_firstname/partner.py 2013-08-12 06:18:39 +0000
682+++ partner_firstname/partner.py 2014-01-22 23:37:10 +0000
683@@ -17,49 +17,68 @@
684 # along with this program. If not, see <http://www.gnu.org/licenses/>.
685 #
686 ##############################################################################
687-from openerp.osv.orm import Model, fields
688-
689-
690-class ResPartner(Model):
691+
692+from openerp.osv import orm, fields
693+
694+
695+class res_partner(orm.Model):
696 """Adds lastname and firstname, name become a stored function field"""
697
698 _inherit = 'res.partner'
699
700- def init(self, cursor):
701- cursor.execute('SELECT id FROM res_partner WHERE lastname IS NOT NULL Limit 1')
702- if not cursor.fetchone():
703- cursor.execute('UPDATE res_partner set lastname = name WHERE name IS NOT NULL')
704+ def _display_name_compute(self, cr, uid, ids, name, args, context=None):
705+ return dict(self.name_get(cr, uid, ids, context=context))
706
707- def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None):
708- res = {}
709- partners = self.read(cursor, uid, ids,
710- ['firstname', 'lastname'], context=context)
711- for rec in partners:
712- names = (rec['lastname'], rec['firstname'])
713- fullname = " ".join([s for s in names if s])
714- res[rec['id']] = fullname
715+ def name_get(self, cr, uid, ids, context=None):
716+ """ By pass of name_get to use directly firstname and lastname
717+ as we cannot ensure name as already been computed when calling this
718+ method for display_name"""
719+ if context is None:
720+ context = {}
721+ if isinstance(ids, (int, long)):
722+ ids = [ids]
723+ res = []
724+ for record in self.browse(cr, uid, ids, context=context):
725+ names = (record.firstname, record.name)
726+ name = u" ".join([s for s in names if s])
727+ if record.parent_id and not record.is_company:
728+ name = "%s, %s" % (record.parent_id.name, name)
729+ if context.get('show_address'):
730+ name = name + "\n" + self._display_address(cr, uid, record, without_company=True, context=context)
731+ name = name.replace('\n\n', '\n')
732+ name = name.replace('\n\n', '\n')
733+ if context.get('show_email') and record.email:
734+ name = "%s <%s>" % (name, record.email)
735+ res.append((record.id, name))
736 return res
737
738- def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None):
739- return self.write(cursor, uid, partner_id,
740- {'lastname': field_value}, context=context)
741-
742- def create(self, cursor, uid, vals, context=None):
743- """To support data backward compatibility we have to keep this overwrite even if we
744- use fnct_inv: otherwise we can't create entry because lastname is mandatory and module
745- will not install if there is demo data"""
746- to_use = vals
747- if vals.get('name'):
748- corr_vals = vals.copy()
749- corr_vals['lastname'] = corr_vals['name']
750- del(corr_vals['name'])
751- to_use = corr_vals
752- return super(ResPartner, self).create(cursor, uid, to_use, context=context)
753-
754- _columns = {'name': fields.function(_compute_name_custom, string="Name",
755- type="char", store=True,
756- select=True, readonly=True,
757- fnct_inv=_write_name),
758-
759- 'firstname': fields.char("Firstname"),
760- 'lastname': fields.char("Lastname", required=True)}
761+ def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
762+ if args is None:
763+ args = []
764+ if context is None:
765+ context = {}
766+ if name:
767+ ids = self.search(cr, uid, [('full_name', operator, name)] + args, limit=limit, context=context)
768+ else:
769+ ids = self.search(cr, uid, args, limit=limit, context=context or {})
770+ return self.name_get(cr, uid, ids, context=context)
771+
772+ def get_full_name(self, cr, uid, ids, field_name, arg, context=None):
773+ return dict(self.name_get(cr, uid, ids, context=context))
774+
775+ _display_name_store_triggers = {
776+ 'res.partner': (lambda self, cr, uid, ids, context=None: self.search(cr, uid, [('id', 'child_of', ids)]),
777+ ['parent_id', 'is_company', 'name', 'firstname'], 10)
778+ }
779+
780+ # indirection to avoid passing a copy of the overridable method when declaring the function field
781+ _display_name = lambda self, *args, **kwargs: self._display_name_compute(*args, **kwargs)
782+
783+ _columns = {
784+ 'full_name': fields.function(_display_name, type='char',
785+ string='Full name',
786+ store=_display_name_store_triggers,
787+ help="First name."),
788+ 'firstname': fields.char("First name", help="First name.")
789+ }
790+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
791
792=== modified file 'partner_firstname/partner_view.xml'
793--- partner_firstname/partner_view.xml 2013-11-13 16:18:13 +0000
794+++ partner_firstname/partner_view.xml 2014-01-22 23:37:10 +0000
795@@ -1,51 +1,54 @@
796 <openerp>
797 <data>
798- <record id="view_partner_simple_form_firstname" model="ir.ui.view">
799- <field name="name">res.partner.simplified.form.firstname</field>
800- <field name="model">res.partner</field>
801- <field name="inherit_id" ref="base.view_partner_simple_form"/>
802- <field name="arch" type="xml">
803- <field name="name" position="attributes">
804- <attribute name="attrs">{'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]}</attribute>
805- </field>
806- <field name="category_id" position="before">
807- <group attrs="{'invisible': [('is_company', '=', True)]}">
808- <field name="lastname" attrs="{'required': [('is_company', '=', False)]}"/>
809- <field name="firstname" />
810- </group>
811- </field>
812- </field>
813- </record>
814
815 <record id="view_partner_form_firstname" model="ir.ui.view">
816 <field name="name">res.partner.form.firstname</field>
817 <field name="model">res.partner</field>
818 <field name="inherit_id" ref="base.view_partner_form"/>
819 <field name="arch" type="xml">
820- <field name="name" position="attributes">
821- <attribute name="attrs">{'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]}</attribute>
822- </field>
823+ <field name="name" position="replace"/>
824 <field name="category_id" position="before">
825 <group attrs="{'invisible': [('is_company', '=', True)]}">
826- <field name="lastname" attrs="{'required': [('is_company', '=', False)]}"/>
827- <field name="firstname"/>
828+ <field name="firstname" attrs="{'required': [('is_company', '=', False)]}"/>
829+ </group>
830+ <group>
831+ <field name="name" position="attributes">
832+ <attribute name="attrs">{'readonly': [('is_company', '=', False)], 'required': [('is_company', '=', True)]}</attribute>
833+ </field>
834 </group>
835 </field>
836- <!-- Add firstname and last name in inner contact form of child_ids -->
837- <xpath expr="//form[@string='Contact']/sheet/div" position="after">
838- <group attrs="{'invisible': [('is_company', '=', True)]}">
839- <field name="lastname" attrs="{'required': [('is_company', '=', False)]}"/>
840+
841+ <!-- Add first name and name in inner contact form of child_ids -->
842+ <xpath expr="//form[@string='Contact']/sheet/div/h1/field[@name='name']" position="replace"/>
843+ <xpath expr="//form[@string='Contact']/sheet/div/label" position="after">
844+ <group>
845 <field name="firstname"/>
846- </group>
847- </xpath>
848- <xpath expr="//form[@string='Contact']/sheet/div/h1" position="after">
849- <field name="is_company" on_change="onchange_type(is_company)" class="oe_inline"/>
850- <label for="is_company" string="Is a Company?"/>)
851- </xpath>
852-
853-
854+ <field name="name"/>
855+ </group>
856+ </xpath>
857+
858+ <label for="name" position="attributes">
859+ <attribute name="invisible">1</attribute>
860+ </label>
861+ <!-- Add first name and name in inner contact kanban view -->
862+ <xpath expr="//t[@t-name='kanban-box']//div[@class='oe_module_desc']//field[@name='name']" position="replace">
863+ <field name="firstname"/>
864+ <field name="name"/>
865+ </xpath>
866 </field>
867 </record>
868+ <!-- Search view with full name-->
869+ <record id="view_res_partner_filter_firstname" model="ir.ui.view">
870+ <field name="name">res.partner.select</field>
871+ <field name="model">res.partner</field>
872+ <field name="inherit_id" ref="base.view_res_partner_filter"/>
873+ <field name="arch" type="xml">
874+ <field name="name" position="replace">
875+ <field name="name"
876+ filter_domain="['|','|',('full_name','ilike',self),('parent_id','ilike',self),('ref','=',self)]"/>
877+ </field>
878+ </field>
879+ </record>
880
881 </data>
882 </openerp>
883
884=== modified file 'partner_firstname/res_user.py'
885--- partner_firstname/res_user.py 2013-02-20 14:00:17 +0000
886+++ partner_firstname/res_user.py 2014-01-22 23:37:10 +0000
887@@ -17,10 +17,11 @@
888 # along with this program. If not, see <http://www.gnu.org/licenses/>.
889 #
890 ##############################################################################
891-from openerp.osv import orm
892-
893-
894-class ResUsers(orm.Model):
895+
896+from openerp.osv import orm, fields
897+
898+
899+class res_user(orm.Model):
900 """Allows user creation from user form as
901 name is not in form"""
902
903@@ -29,4 +30,4 @@
904 def create(self, cursor, uid, vals, context=None):
905 if not vals.get('name'):
906 vals['name'] = vals['login']
907- return super(ResUsers, self).create(cursor, uid, vals, context=context)
908+ return super(res_user, self).create(cursor, uid, vals, context=context)

Subscribers

People subscribed via source and target branches

to all changes: