Merge lp:~julie-w/unifield-server/US-4759 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5044
Proposed branch: lp:~julie-w/unifield-server/US-4759
Merge into: lp:unifield-server
Diff against target: 111 lines (+40/-5) (has conflicts)
2 files modified
bin/addons/msf_homere_interface/wizard/hr_payroll_employee_import.py (+31/-5)
bin/addons/msf_profile/i18n/fr_MF.po (+9/-0)
Text conflict in bin/addons/msf_profile/i18n/fr_MF.po
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-4759
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+352739@code.launchpad.net
To post a comment you must log in.
lp:~julie-w/unifield-server/US-4759 updated
5007. By Julie Nuguet on 2018-08-14

US-4759 [IMP] Import of employees / check the PER_MOIS format: remove the check on 'TYPE_ENVOI' (its value is not always written in English + the other critera are enough to distinguish between the files)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/msf_homere_interface/wizard/hr_payroll_employee_import.py'
2--- bin/addons/msf_homere_interface/wizard/hr_payroll_employee_import.py 2018-07-19 13:11:25 +0000
3+++ bin/addons/msf_homere_interface/wizard/hr_payroll_employee_import.py 2018-08-14 13:29:44 +0000
4@@ -37,6 +37,8 @@
5 import subprocess
6 import os
7 import shutil
8+import ConfigParser
9+
10
11 def get_7z():
12 if os.name == 'nt':
13@@ -534,23 +536,31 @@
14 staff_file = 'staff.csv'
15 contract_file = 'contrat.csv'
16 job_file = 'fonction.csv'
17+ ini_file = 'envoi.ini'
18 job_reader =False
19 contract_reader = False
20 staff_reader = False
21+ config_parser = False
22 desc_to_close = []
23 tmpdir = False
24 if is_zipfile(filename):
25 zipobj = zf(filename)
26+ if zipobj:
27+ desc_to_close.append(zipobj)
28 if zipobj.namelist() and job_file in zipobj.namelist():
29 job_reader = csv.DictReader(zipobj.open(job_file), quotechar='"', delimiter=',', doublequote=False, escapechar='\\')
30 # Do not raise error for job file because it's just a useful piece of data, but not more.
31- # read the contract file
32+ # read the contract file
33 if zipobj.namelist() and contract_file in zipobj.namelist():
34 contract_reader = csv.DictReader(zipobj.open(contract_file), quotechar='"', delimiter=',', doublequote=False, escapechar='\\')
35- # read the staff file
36+ # read the staff file
37 if zipobj.namelist() and staff_file in zipobj.namelist():
38 # Doublequote and escapechar avoid some problems
39 staff_reader = csv.DictReader(zipobj.open(staff_file), quotechar='"', delimiter=',', doublequote=False, escapechar='\\')
40+ # read the ini file
41+ if zipobj.namelist() and ini_file in zipobj.namelist():
42+ config_parser = ConfigParser.SafeConfigParser()
43+ config_parser.readfp(zipobj.open(ini_file))
44 else:
45 tmpdir = self._extract_7z(cr, uid, filename)
46 job_file_name = os.path.join(tmpdir, job_file)
47@@ -571,11 +581,20 @@
48 desc_to_close.append(staff_file_desc)
49 staff_reader = csv.DictReader(staff_file_desc, quotechar='"', delimiter=',', doublequote=False, escapechar='\\')
50
51+ ini_file_name = os.path.join(tmpdir, ini_file)
52+ if os.path.isfile(ini_file_name):
53+ ini_file_desc = open(ini_file_name, 'rb')
54+ desc_to_close.append(ini_file_desc)
55+ config_parser = ConfigParser.SafeConfigParser()
56+ config_parser.readfp(ini_file_desc)
57+
58 if not contract_reader:
59 raise osv.except_osv(_('Error'), _('%s not found in given zip file!') % (contract_file,))
60 if not staff_reader:
61 raise osv.except_osv(_('Error'), _('%s not found in given zip file!') % (staff_file,))
62- return (job_reader, contract_reader, staff_reader, desc_to_close, tmpdir)
63+ if not config_parser:
64+ raise osv.except_osv(_('Error'), _('%s not found in given zip file!') % (ini_file,))
65+ return job_reader, contract_reader, staff_reader, config_parser, desc_to_close, tmpdir
66
67 def button_validate(self, cr, uid, ids, context=None):
68 """
69@@ -603,9 +622,16 @@
70 # now we determine the file format
71 filename = fileobj.name
72 fileobj.close()
73- job_reader, contract_reader, staff_reader, desc_to_close, tmpdir = self.read_files(cr, uid, filename)
74+ job_reader, contract_reader, staff_reader, config_parser, desc_to_close, tmpdir = self.read_files(cr, uid, filename)
75 filename = wiz.filename or ""
76-
77+ # Check data from the ini file
78+ mois_ko = not config_parser.has_option('DEFAUT', 'MOIS')
79+ liste_terr_ko = not config_parser.has_option('DEFAUT', 'LISTETERRAIN') or \
80+ config_parser.get('DEFAUT', 'LISTETERRAIN').count(';') > 1 # it should contain only 1 project code
81+ if mois_ko or liste_terr_ko:
82+ # block all the import if the file imported is not a valid PER_MOIS file
83+ raise osv.except_osv(_('Error'), _("You can't import this file. Please check that it contains data "
84+ "for only one month and one field."))
85 if job_reader:
86 self.update_job(cr, uid, ids, job_reader, context=context)
87 # Do not raise error for job file because it's just a useful piece of data, but not more.
88
89=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
90--- bin/addons/msf_profile/i18n/fr_MF.po 2018-08-13 16:12:01 +0000
91+++ bin/addons/msf_profile/i18n/fr_MF.po 2018-08-14 13:29:44 +0000
92@@ -101396,6 +101396,7 @@
93 #, python-format
94 msgid "The Location \"%s\" on line level is not the same as the Location \"%s\" on header level."
95 msgstr "La Zone \"%s\" au niveau de la ligne n'est pas la même que la Zone \"%s\" au niveau de l'entête."
96+<<<<<<< TREE
97
98 #. module: account_override
99 #: code:addons/account_override/account.py:1138
100@@ -101530,3 +101531,11 @@
101 #: selection:return.ppl.move.processor,integrity_status:0
102 msgid "The quantity per pack must be a multiple of UoM's rounding"
103 msgstr "La quantité par paquet doit être un multiple de l'arrondi de l'UdM"
104+=======
105+
106+#. module: msf_homere_interface
107+#: code:addons/msf_homere_interface/wizard/hr_payroll_employee_import.py:635
108+#, python-format
109+msgid "You can't import this file. Please check that it contains data for only one month and one field."
110+msgstr "Vous ne pouvez pas importer ce fichier. Veuillez vérifier qu'il contient des données pour seulement un mois et un terrain."
111+>>>>>>> MERGE-SOURCE

Subscribers

People subscribed via source and target branches