Merge lp:~savoirfairelinux-openerp/openerp-hr/unique_code into lp:openerp-hr

Status: Merged
Merged at revision: 74
Proposed branch: lp:~savoirfairelinux-openerp/openerp-hr/unique_code
Merge into: lp:openerp-hr
Diff against target: 139 lines (+121/-0)
3 files modified
hr_department_sequence/hr_department.py (+17/-0)
hr_department_sequence/i18n/fr.po (+52/-0)
hr_department_sequence/i18n/hr_department_sequence.pot (+52/-0)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/openerp-hr/unique_code
Reviewer Review Type Date Requested Status
Daniel Reis lgtm Approve
Maxime Chambreuil (http://www.savoirfairelinux.com) code review Approve
HR Core Editors Pending
Review via email: mp+196184@code.launchpad.net

Description of the change

Added a unique constraint for department codes per company.
Added name_search and name_get as '[CODE] Department name'
Added french locale

To post a comment you must log in.
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve (code review)
Revision history for this message
Daniel Reis (dreis-pt) wrote :

Hello Sandy,

Since you're at it, you could also add the generic .pot file, to make this translatable.

Also, I wouldn't like to have the "name_get" changes here.
I suggest that to be a separate module, so that people can choose to use it or not.
And it should implement that both on "name_get" and "name_search".

I did an implementation for that, and use it in production, doing that both for Departments and Employees. See the "hr_refcodes" ad https://code.launchpad.net/~dreis-pt/reis-openerp-addons/7.0
Arguably, it could be split in two modules.
(And you can find there also modules to display/search Customer and Contract codes).

review: Needs Fixing
68. By El Hadji Dem (http://www.savoirfairelinux.com)

[MRG] hr_skill module

69. By El Hadji Dem (http://www.savoirfairelinux.com)

[MRG] Fix the copyright and update to reflect the new fields and views

70. By El Hadji Dem (http://www.savoirfairelinux.com)

[MRG] hr_language

Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

Thank you for your review, Daniel,

The .pot file is already included, I think you missed it.

What's wrong with an optional custom name_get, it will only display the code if you explicitly say so in the context.
Is it really necessary to divide this module even further. Seems that if you use code for departments, you would want to list them as codes.

71. By Launchpad Translations on behalf of hr-core-editors

Launchpad automatic translations update.

72. By Launchpad Translations on behalf of hr-core-editors

Launchpad automatic translations update.

Revision history for this message
Daniel Reis (dreis-pt) :
review: Approve (lgtm)
73. By Sandy Carter (http://www.savoirfairelinux.com)

[MRG] Specificy on_delete='cascade' for parent_id of hr_department

74. By Sandy Carter (http://www.savoirfairelinux.com)

[MRG] Added a unique constraint for department codes per company.
Added name_search and name_get as '[CODE] Department name'
Added french locale

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_department_sequence/hr_department.py'
2--- hr_department_sequence/hr_department.py 2013-09-23 13:55:07 +0000
3+++ hr_department_sequence/hr_department.py 2013-12-03 19:24:38 +0000
4@@ -37,3 +37,20 @@
5 _parent_store = True
6 _parent_order = 'sequence, name'
7 _order = 'parent_left'
8+ _sql_constraints = [
9+ ('code_uniq', 'unique(code, company_id)', 'The code for the department must be unique per company !'),
10+ ]
11+
12+ def name_get(self, cr, uid, ids, context=None):
13+ """
14+ Show department code with name
15+ """
16+ if isinstance(ids, (int, long)):
17+ ids = [ids]
18+ return [(record.id, '[%s] %s' % (record.code, record.name) if record.code else record.name)
19+ for record in self.browse(cr, uid, ids, context=context or {})]
20+
21+ def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=100):
22+ ids = self.search(cr, uid, ['|', ('code', 'ilike', name), ('name', 'ilike', name)] + args,
23+ limit=limit, context=context)
24+ return self.name_get(cr, uid, ids, context=context)
25
26=== added directory 'hr_department_sequence/i18n'
27=== added file 'hr_department_sequence/i18n/fr.po'
28--- hr_department_sequence/i18n/fr.po 1970-01-01 00:00:00 +0000
29+++ hr_department_sequence/i18n/fr.po 2013-12-03 19:24:38 +0000
30@@ -0,0 +1,52 @@
31+# Translation of OpenERP Server.
32+# This file contains the translation of the following modules:
33+# * hr_department_sequence
34+#
35+msgid ""
36+msgstr ""
37+"Project-Id-Version: OpenERP Server 7.0\n"
38+"Report-Msgid-Bugs-To: \n"
39+"POT-Creation-Date: 2013-11-21 19:08+0000\n"
40+"PO-Revision-Date: 2013-11-21 14:12-0500\n"
41+"Last-Translator: Sandy Carter <sandy.carter@savoirfairelinux.com>\n"
42+"Language-Team: Savoir-faire Linux <http://www.savoirfairelinux.com>\n"
43+"MIME-Version: 1.0\n"
44+"Content-Type: text/plain; charset=UTF-8\n"
45+"Content-Transfer-Encoding: 8bit\n"
46+"X-Generator: Poedit 1.5.7\n"
47+"Language: fr\n"
48+
49+#. module: hr_department_sequence
50+#: field:hr.department,parent_left:0
51+msgid "Left Parent"
52+msgstr "Parent de gauche"
53+
54+#. module: hr_department_sequence
55+#: field:hr.department,code:0
56+msgid "Code"
57+msgstr "Code"
58+
59+#. module: hr_department_sequence
60+#: field:hr.department,sequence:0
61+msgid "Sequence"
62+msgstr "Séquence"
63+
64+#. module: hr_department_sequence
65+#: help:hr.department,sequence:0
66+msgid "Gives the sequence order when displaying a list of departments."
67+msgstr "Donne l'ordre dans la liste des départements."
68+
69+#. module: hr_department_sequence
70+#: sql_constraint:hr.department:0
71+msgid "The code for the department must be unique per company !"
72+msgstr "Le code d'un département doit être unique par compagnie !"
73+
74+#. module: hr_department_sequence
75+#: model:ir.model,name:hr_department_sequence.model_hr_department
76+msgid "Department"
77+msgstr "Département"
78+
79+#. module: hr_department_sequence
80+#: field:hr.department,parent_right:0
81+msgid "Right Parent"
82+msgstr "Parent de droite"
83
84=== added file 'hr_department_sequence/i18n/hr_department_sequence.pot'
85--- hr_department_sequence/i18n/hr_department_sequence.pot 1970-01-01 00:00:00 +0000
86+++ hr_department_sequence/i18n/hr_department_sequence.pot 2013-12-03 19:24:38 +0000
87@@ -0,0 +1,52 @@
88+# Translation of OpenERP Server.
89+# This file contains the translation of the following modules:
90+# * hr_department_sequence
91+#
92+msgid ""
93+msgstr ""
94+"Project-Id-Version: OpenERP Server 7.0\n"
95+"Report-Msgid-Bugs-To: \n"
96+"POT-Creation-Date: 2013-11-21 19:08+0000\n"
97+"PO-Revision-Date: 2013-11-21 19:08+0000\n"
98+"Last-Translator: <>\n"
99+"Language-Team: \n"
100+"MIME-Version: 1.0\n"
101+"Content-Type: text/plain; charset=UTF-8\n"
102+"Content-Transfer-Encoding: \n"
103+"Plural-Forms: \n"
104+
105+#. module: hr_department_sequence
106+#: field:hr.department,parent_left:0
107+msgid "Left Parent"
108+msgstr ""
109+
110+#. module: hr_department_sequence
111+#: field:hr.department,code:0
112+msgid "Code"
113+msgstr ""
114+
115+#. module: hr_department_sequence
116+#: field:hr.department,sequence:0
117+msgid "Sequence"
118+msgstr ""
119+
120+#. module: hr_department_sequence
121+#: help:hr.department,sequence:0
122+msgid "Gives the sequence order when displaying a list of departments."
123+msgstr ""
124+
125+#. module: hr_department_sequence
126+#: sql_constraint:hr.department:0
127+msgid "The code for the department must be unique per company !"
128+msgstr ""
129+
130+#. module: hr_department_sequence
131+#: model:ir.model,name:hr_department_sequence.model_hr_department
132+msgid "Department"
133+msgstr ""
134+
135+#. module: hr_department_sequence
136+#: field:hr.department,parent_right:0
137+msgid "Right Parent"
138+msgstr ""
139+