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
=== modified file 'hr_department_sequence/hr_department.py'
--- hr_department_sequence/hr_department.py 2013-09-23 13:55:07 +0000
+++ hr_department_sequence/hr_department.py 2013-12-03 19:24:38 +0000
@@ -37,3 +37,20 @@
37 _parent_store = True37 _parent_store = True
38 _parent_order = 'sequence, name'38 _parent_order = 'sequence, name'
39 _order = 'parent_left'39 _order = 'parent_left'
40 _sql_constraints = [
41 ('code_uniq', 'unique(code, company_id)', 'The code for the department must be unique per company !'),
42 ]
43
44 def name_get(self, cr, uid, ids, context=None):
45 """
46 Show department code with name
47 """
48 if isinstance(ids, (int, long)):
49 ids = [ids]
50 return [(record.id, '[%s] %s' % (record.code, record.name) if record.code else record.name)
51 for record in self.browse(cr, uid, ids, context=context or {})]
52
53 def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=100):
54 ids = self.search(cr, uid, ['|', ('code', 'ilike', name), ('name', 'ilike', name)] + args,
55 limit=limit, context=context)
56 return self.name_get(cr, uid, ids, context=context)
4057
=== added directory 'hr_department_sequence/i18n'
=== added file 'hr_department_sequence/i18n/fr.po'
--- hr_department_sequence/i18n/fr.po 1970-01-01 00:00:00 +0000
+++ hr_department_sequence/i18n/fr.po 2013-12-03 19:24:38 +0000
@@ -0,0 +1,52 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * hr_department_sequence
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-11-21 19:08+0000\n"
10"PO-Revision-Date: 2013-11-21 14:12-0500\n"
11"Last-Translator: Sandy Carter <sandy.carter@savoirfairelinux.com>\n"
12"Language-Team: Savoir-faire Linux <http://www.savoirfairelinux.com>\n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"X-Generator: Poedit 1.5.7\n"
17"Language: fr\n"
18
19#. module: hr_department_sequence
20#: field:hr.department,parent_left:0
21msgid "Left Parent"
22msgstr "Parent de gauche"
23
24#. module: hr_department_sequence
25#: field:hr.department,code:0
26msgid "Code"
27msgstr "Code"
28
29#. module: hr_department_sequence
30#: field:hr.department,sequence:0
31msgid "Sequence"
32msgstr "Séquence"
33
34#. module: hr_department_sequence
35#: help:hr.department,sequence:0
36msgid "Gives the sequence order when displaying a list of departments."
37msgstr "Donne l'ordre dans la liste des départements."
38
39#. module: hr_department_sequence
40#: sql_constraint:hr.department:0
41msgid "The code for the department must be unique per company !"
42msgstr "Le code d'un département doit être unique par compagnie !"
43
44#. module: hr_department_sequence
45#: model:ir.model,name:hr_department_sequence.model_hr_department
46msgid "Department"
47msgstr "Département"
48
49#. module: hr_department_sequence
50#: field:hr.department,parent_right:0
51msgid "Right Parent"
52msgstr "Parent de droite"
053
=== added file 'hr_department_sequence/i18n/hr_department_sequence.pot'
--- hr_department_sequence/i18n/hr_department_sequence.pot 1970-01-01 00:00:00 +0000
+++ hr_department_sequence/i18n/hr_department_sequence.pot 2013-12-03 19:24:38 +0000
@@ -0,0 +1,52 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * hr_department_sequence
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-11-21 19:08+0000\n"
10"PO-Revision-Date: 2013-11-21 19:08+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: hr_department_sequence
19#: field:hr.department,parent_left:0
20msgid "Left Parent"
21msgstr ""
22
23#. module: hr_department_sequence
24#: field:hr.department,code:0
25msgid "Code"
26msgstr ""
27
28#. module: hr_department_sequence
29#: field:hr.department,sequence:0
30msgid "Sequence"
31msgstr ""
32
33#. module: hr_department_sequence
34#: help:hr.department,sequence:0
35msgid "Gives the sequence order when displaying a list of departments."
36msgstr ""
37
38#. module: hr_department_sequence
39#: sql_constraint:hr.department:0
40msgid "The code for the department must be unique per company !"
41msgstr ""
42
43#. module: hr_department_sequence
44#: model:ir.model,name:hr_department_sequence.model_hr_department
45msgid "Department"
46msgstr ""
47
48#. module: hr_department_sequence
49#: field:hr.department,parent_right:0
50msgid "Right Parent"
51msgstr ""
52