Merge lp:~jfb-tempo-consulting/unifield-server/US-9730 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 6252
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-9730
Merge into: lp:unifield-server
Diff against target: 175 lines (+39/-6)
3 files modified
bin/addons/msf_homere_interface/hr_payroll_wizard.xml (+2/-1)
bin/addons/msf_homere_interface/wizard/hr_payroll_import.py (+31/-5)
bin/addons/msf_profile/i18n/fr_MF.po (+6/-0)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-9730
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+424863@code.launchpad.net
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=== modified file 'bin/addons/msf_homere_interface/hr_payroll_wizard.xml'
2--- bin/addons/msf_homere_interface/hr_payroll_wizard.xml 2020-09-21 12:51:01 +0000
3+++ bin/addons/msf_homere_interface/hr_payroll_wizard.xml 2022-06-16 15:00:29 +0000
4@@ -173,9 +173,10 @@
5 <field name="file" filename="filename"/>
6 <field name="filename" invisible="1"/>
7 <field name="date_format"/>
8+ <field name="blocked" invisible="1" />
9 <newline/>
10 <group colspan="4" col="2"
11- attrs="{'invisible': [('state', '=', 'simu')]}">
12+ attrs="{'invisible': [('blocked', '=', False), ('state', '=', 'simu')]}">
13 <field name="msg" colspan="4"/>
14 </group>
15 <group colspan="4" col="2"
16
17=== modified file 'bin/addons/msf_homere_interface/wizard/hr_payroll_import.py'
18--- bin/addons/msf_homere_interface/wizard/hr_payroll_import.py 2022-04-08 09:11:56 +0000
19+++ bin/addons/msf_homere_interface/wizard/hr_payroll_import.py 2022-06-16 15:00:29 +0000
20@@ -73,6 +73,7 @@
21 'filename': fields.char(string="Imported filename", size=256),
22 'date_format': fields.selection([('%d/%m/%Y', 'dd/mm/yyyy'), ('%m-%d-%Y', 'mm-dd-yyyy'), ('%d-%m-%y', 'dd-mm-yy'), ('%d-%m-%Y', 'dd-mm-yyyy'), ('%d/%m/%y', 'dd/mm/yy'), ('%d.%m.%Y', 'dd.mm.yyyy')], "Date format", required=True, help="This is the date format used in the Homère file in order to recognize them."),
23 'msg': fields.text(string='Message'),
24+ 'blocked': fields.boolean('Is import blocked'),
25 }
26
27 _defaults = {
28@@ -131,6 +132,7 @@
29 created = 0
30 vals = {}
31 error_message = ""
32+ blocking_message = []
33 # verify that some data exists
34 if not data:
35 return False, res_amount, created, vals, "", error_message, bs_only
36@@ -143,10 +145,13 @@
37 name = ''
38 ref = ''
39 destination_id = False
40+ destination_code = False
41 cost_center_id = False
42+ cost_center_code = False
43 # US-671: This flag is used to indicate whether the DEST and CC of employee needs to be updated
44 to_update_employee = False
45 partner_obj = self.pool.get('res.partner')
46+ ad_obj = self.pool.get('analytic.distribution')
47
48 # strip spaces in all columns
49 for i in range(len(data)):
50@@ -170,6 +175,7 @@
51 cc_ids = aaa_obj.search(cr, uid, condition, context=context)
52 if cc_ids and cc_ids[0]:
53 cost_center_id = cc_ids[0]
54+ cost_center_code = project[0]
55 else:
56 error_message = _("Invalid Cost Center [%s] will be ignored.") % (project[0])
57 if axis1 and axis1[0]:
58@@ -179,6 +185,7 @@
59 dest_ids = aaa_obj.search(cr, uid, date_args, context=context)
60 if dest_ids and dest_ids[0]:
61 destination_id = dest_ids[0]
62+ destination_code = axis1[0]
63 else:
64 error_message = error_message + _("Invalid Destination [%s] will be ignored.") % (axis1[0])
65
66@@ -272,10 +279,12 @@
67
68 if not destination_id and emp.destination_id: # US-671: Only update if the destination from the import is not valid
69 destination_id = emp.destination_id.id
70+ destination_code = emp.destination_id.code
71 if not destination_id:
72 if not account.default_destination_id:
73 raise osv.except_osv(_('Warning'), _('No default Destination defined for this account: %s') % (account.code or '',))
74 destination_id = account.default_destination_id and account.default_destination_id.id or False
75+ destination_code = account.default_destination_id and account.default_destination_id.code or False
76
77 # Fetch description
78 if not name:
79@@ -312,19 +321,27 @@
80 }
81 # Retrieve analytic distribution from employee
82 if employee_id:
83- employee_data = self.pool.get('hr.employee').read(cr, uid, employee_id, ['cost_center_id', 'funding_pool_id', 'free1_id', 'free2_id'])
84+ employee_data = self.pool.get('hr.employee').read(cr, uid, employee_id, ['cost_center_id', 'funding_pool_id', 'free1_id', 'free2_id', 'name_resource'])
85 #US-671: use the cost center from the import, if not retrieve from employee
86 temp_cc = employee_data and employee_data.get('cost_center_id', False) and employee_data.get('cost_center_id')[0] or False
87 if cost_center_id and cost_center_id != temp_cc:
88 to_update_employee =True
89 if not cost_center_id:
90 cost_center_id = temp_cc
91+ cost_center_code = employee_data.get('cost_center_id') and employee_data.get('cost_center_id')[1] or False
92 vals.update({
93 'cost_center_id': cost_center_id,
94 'funding_pool_id': employee_data and employee_data.get('funding_pool_id', False) and employee_data.get('funding_pool_id')[0] or False,
95 'free1_id': employee_data and employee_data.get('free1_id', False) and employee_data.get('free1_id')[0] or False,
96 'free2_id': employee_data and employee_data.get('free2_id', False) and employee_data.get('free2_id')[0] or False,
97 })
98+ if wiz_state == 'simu' and to_update_employee:
99+ #check cc compat on (cost_center_id, destination_id, employee_data.funding_pool_id)
100+ if cost_center_id and destination_id and not ad_obj.check_dest_cc_compatibility(cr, uid, destination_id, cost_center_id, context=context):
101+ blocking_message.append(_('Employee %s: the Cost Center %s is not compatible with the Destination %s.') % (employee_data['name_resource'], cost_center_code, destination_code))
102+ fp_id = employee_data.get('funding_pool_id', False) and employee_data.get('funding_pool_id')[0]
103+ if fp_id and cost_center_id and not ad_obj.check_fp_cc_compatibility(cr, uid, fp_id, cost_center_id, context=context):
104+ blocking_message.append(_('Employee %s: the Cost Center %s is not compatible with the Funding Pool %s.') % (employee_data['name_resource'], cost_center_code, employee_data.get('funding_pool_id')[1]))
105 # Write payroll entry
106 if wiz_state != 'simu':
107 #US-671: In the process mode, update the employee cost center and destination, and use also this one for the payroll object.
108@@ -338,7 +355,7 @@
109 created += 1
110 else:
111 created += 1
112- return True, amount, created, vals, currency[0], error_message, bs_only
113+ return True, amount, created, vals, currency[0], error_message, blocking_message, bs_only
114
115 def _get_homere_password(self, cr, uid, pass_type='payroll'):
116 ##### UPDATE HOMERE.CONF FILE #####
117@@ -507,6 +524,7 @@
118
119 filename = ""
120 error_msg = ""
121+ blocking_msg = []
122 wiz_state = False
123 # Browse all given wizard
124 for wiz in self.browse(cr, uid, ids):
125@@ -569,12 +587,14 @@
126 for line in reader:
127 num_line += 1
128 processed += 1
129- update, amount, nb_created, vals, ccy, msg, bs_only = self.update_payroll_entries(
130+ update, amount, nb_created, vals, ccy, msg, blocking_message, bs_only = self.update_payroll_entries(
131 cr, uid, data=line, field=field,
132 date_format=wiz.date_format,
133 wiz_state=wiz.state,
134 bs_only=bs_only)
135 res_amount += round(amount, 2)
136+ for block in blocking_message:
137+ blocking_msg.append(_("Line %s: %s") % (str(num_line), block))
138 if not update:
139 res = False
140 if num_line == 2: # the first line containing data
141@@ -646,12 +666,18 @@
142 if wiz_state == 'simu' and ids:
143 # US_201: if check raise no error, change state to process
144 # US-671: Show message in the wizard if there was warning or not.
145- if error_msg:
146+ wiz_state = 'proceed'
147+ blocked = False
148+ if blocking_msg:
149+ error_msg = '%s:\n--------------------\n%s' % (_('Please correct following employee analytic distribution errors to allow Import to be processed'), "\n".join(blocking_msg))
150+ wiz_state = 'simu'
151+ blocked = True
152+ elif error_msg:
153 error_msg = _("Import can be processed but with the following warnings:\n-------------------- \n") + error_msg
154 else:
155 error_msg = _("No warning found for this file. Import can be now processed.")
156
157- self.write(cr, uid, [wiz.id], {'state': 'proceed', 'msg': error_msg})
158+ self.write(cr, uid, [wiz.id], {'state': wiz_state, 'msg': error_msg, 'blocked': blocked})
159 view_id = self.pool.get('ir.model.data').get_object_reference(cr,
160 uid, 'msf_homere_interface', 'payroll_import_wizard')
161 view_id = view_id and view_id[1] or False
162
163=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
164--- bin/addons/msf_profile/i18n/fr_MF.po 2022-05-25 14:15:34 +0000
165+++ bin/addons/msf_profile/i18n/fr_MF.po 2022-06-16 15:00:29 +0000
166@@ -115048,3 +115048,9 @@
167 #, python-format
168 msgid "Cannot update these products, ED/BN attributes have not changed since the KCL creation"
169 msgstr "Impossible de mettre à jour ces produits. Les attributs NL/DE n'ont pas changé depuis la création du Kit"
170+
171+#. module: msf_homere_interface
172+#: code:addons/msf_homere_interface/wizard/hr_payroll_import.py:669
173+#, python-format
174+msgid "Please correct following employee analytic distribution errors to allow Import to be processed"
175+msgstr "Veuillez corriger les erreurs suivantes de distribution analytique des employés pour pouvoir finaliser l'import des données:"

Subscribers

People subscribed via source and target branches