47
47
def create_hrself_code_list(self,cr,uid,values):
48
48
"""Create a HRSelf code list.
51
@return: identifier of created HRSelf code list
52
:return: identifier of created HRSelf code list
53
54
return self._create_update_object_translation(cr, uid, None, 'hrself.code.list', values)
55
56
def update_hrself_code_list(self,cr,uid,id,values):
56
57
"""Update a HRSelf code list.
57
@param id: HRSelf code list identifier
61
@return: True on sucess, False on failure
59
:param id: HRSelf code list identifier
63
:return: True on sucess, False on failure
63
65
result = self.pool.get('hrself.code.list').write(cr,uid,id,values)
64
66
logger.info('hrself.code.list %d updated' % id)
67
69
def read_hrself_code_list(self,cr,uid,identifier,value):
68
70
"""Read a HRSelf code list identified in Groupe S by (identifier, value).
69
@param identifier: Groupe S code list identifier
70
@type identifier: integer
71
@param identifier: Groupe S code list value
72
@type identifier: integer
73
@return: Field values if HRSelf code list exists, False otherwise
74
@rtype: dict or boolean"""
72
:param identifier: Groupe S code list identifier
73
:type identifier: integer
74
:param identifier: Groupe S code list value
75
:type identifier: integer
76
:return: Field values if HRSelf code list exists, False otherwise
77
:rtype: dict or boolean"""
75
78
code_list_object = self.pool.get('hrself.code.list')
76
79
code_list_ids = code_list_object.search(cr,uid,[('groupes_id', '=', identifier), ('groupes_num_value', '=', value)])
84
87
def create_hrself_prestation_code(self, cr, uid, values):
85
88
"""Create a HRSelf prestation code.
88
@return: identifier of created HRSelf prestation code
92
:return: identifier of created HRSelf prestation code
90
94
return self._create_update_object_translation(cr, uid, None, 'hrself.prestation.code', values)
92
96
def update_hrself_prestation_code(self, cr, uid, id, values):
93
97
"""Update a HRSelf prestation code.
94
@param id: HRSelf prestation code identifier
98
@return: True on sucess, False on failure
99
:param id: HRSelf prestation code identifier
101
:param values: Values
103
:return: True on sucess, False on failure
100
105
return self._create_update_object_translation(cr, uid, id, 'hrself.prestation.code', values)
102
107
def read_hrself_prestation_code(self, cr, uid, employer_id, mnemonic):
103
108
"""Read a HRSelf prestation code identified in Groupe S by (employer_id, mnemonic).
104
@param employer_id: Groupe S employer identifier
105
@type employer_id: integer
106
@param mnemonic: Groupe S mnemonic
108
@return: Field values if HRSelf prestation code exists, False otherwise
109
@rtype: dict or boolean"""
110
:param employer_id: Groupe S employer identifier
111
:type employer_id: integer
112
:param mnemonic: Groupe S mnemonic
114
:return: Field values if HRSelf prestation code exists, False otherwise
115
:rtype: dict or boolean"""
111
117
employer_object = self.pool.get('hrself.employer')
112
118
employer_ids = employer_object.search(cr, uid, [('groupes_id', '=', employer_id)])
128
134
def create_hrself_counter_type(self, cr, uid, values):
129
135
"""Create a HRSelf counter type.
130
@param values: Values
132
@return: identifier of created HRSelf counter type
137
:param values: Values
139
:return: identifier of created HRSelf counter type
134
141
return self._create_update_object_translation(cr, uid, None, 'hrself.counter.type', self._hrself_counter_type_values(values))
136
143
def update_hrself_counter_type(self, cr, uid, id, values):
137
144
"""Update a HRSelf counter type.
138
@param id: HRSelf counter type identifier
140
@param values: Values
142
@return: True on sucess, False on failure
146
:param id: HRSelf counter type identifier
148
:param values: Values
150
:return: True on sucess, False on failure
144
152
return self._create_update_object_translation(cr, uid, id, 'hrself.counter.type', self._hrself_counter_type_values(values))
146
154
def _hrself_counter_type_values(self, values):
147
155
"""OpenERP counter type values corresponding to Groupe S values.
148
@param values: Groupe S values
150
@return: OpenERP values
157
:param values: Groupe S values
159
:return: OpenERP values
152
161
result = dict(values)
153
162
if values.get('init_date'):
154
163
result['init_date'] = hrself_datetime.to_date(values['init_date'].value, hrself_datetime.XML_RPC_DATETIME_FORMAT)
157
166
def read_hrself_counter_type(self, cr, uid, employer_id, mnemonic):
158
167
"""Read a HRSelf counter type identified in Groupe S by (employer_id, mnemonic).
159
@param employer_id: Groupe S employer identifier
160
@type employer_id: integer
161
@param mnemonic: Groupe S mnemonic
163
@return: Field values if HRSelf counter type exists, False otherwise
164
@rtype: dict or boolean"""
169
:param employer_id: Groupe S employer identifier
170
:type employer_id: integer
171
:param mnemonic: Groupe S mnemonic
173
:return: Field values if HRSelf counter type exists, False otherwise
174
:rtype: dict or boolean"""
165
175
employer_object = self.pool.get('hrself.employer')
166
176
employer_ids = employer_object.search(cr, uid, [('groupes_id', '=', employer_id)])
167
177
counter_type_object = self.pool.get('hrself.counter.type')
180
190
def create_hrself_universe(self,cr,uid,values):
181
191
"""Create a HRSelf universe.
182
@param values: Values
184
@return: identifier of created HRSelf universe
193
:param values: Values
195
:return: identifier of created HRSelf universe
186
197
universe_object = self.pool.get('hrself.universe')
187
198
universe_id = universe_object.create(cr,uid,values)
188
199
logger.info('hrself.universe %d created' % universe_id)
209
220
def update_hrself_universe(self,cr,uid,id,values):
210
221
"""Update a HRSelf universe.
211
@param id: HRSelf universe identifier
213
@param values: Values
215
@return: True on sucess, False on failure
223
:param id: HRSelf universe identifier
225
:param values: Values
227
:return: True on sucess, False on failure
217
229
result = self.pool.get('hrself.universe').write(cr,uid,id,values)
218
230
logger.info('hrself.universe %d updated' % id)
221
233
def read_hrself_universe(self,cr,uid,identifier):
222
234
"""Read a HRSelf universe identified in Groupe S by identifier.
223
@param identifier: Groupe S universe identifier
224
@type identifier: integer
225
@return: Field values if HRSelf universe exists, False otherwise
226
@rtype: dict or boolean"""
236
:param identifier: Groupe S universe identifier
237
:type identifier: integer
238
:return: Field values if HRSelf universe exists, False otherwise
239
:rtype: dict or boolean"""
227
240
universe_object = self.pool.get('hrself.universe')
228
241
universe_ids = universe_object.search(cr,uid,[('groupes_id', '=', identifier)])
234
247
def create_hrself_employer(self,cr,uid,values):
235
248
"""Create a HRSelf employer.
236
@param values: Values
238
@return: identifier of created HRSelf employer
250
:param values: Values
252
:return: identifier of created HRSelf employer
240
254
employer_id = self.pool.get('hrself.employer').create(cr,uid,values)
241
255
logger.info('hrself.employer %d created' % employer_id)
242
256
return employer_id
244
258
def update_hrself_employer(self,cr,uid,id,values):
245
259
"""Update a HRSelf employer.
246
@param id: HRSelf employer identifier
248
@param values: Values
250
@return: True on sucess, False on failure
261
:param id: HRSelf employer identifier
263
:param values: Values
265
:return: True on sucess, False on failure
254
269
def read_hrself_employer(self,cr,uid,universe_identifier,employer_identifier):
255
270
"""Read a HRSelf employer identified in Groupe S by (universe_identifier, employer_identifier).
256
@param universe_identifier: Groupe S universe identifier
257
@type universe_identifier: integer
258
@param employer_identifier: Groupe S employer identifier
259
@type person_identifier: integer
260
@return: Field values if HRSelf employer exists, False otherwise
261
@rtype: dict or boolean"""
272
:param universe_identifier: Groupe S universe identifier
273
:type universe_identifier: integer
274
:param employer_identifier: Groupe S employer identifier
275
:type person_identifier: integer
276
:return: Field values if HRSelf employer exists, False otherwise
277
:rtype: dict or boolean"""
262
278
universe_object = self.pool.get('hrself.universe')
263
279
universe_ids = universe_object.search(cr,uid,[('groupes_id', '=', universe_identifier)])
264
280
employer_object = self.pool.get('hrself.employer')
273
289
def create_hrself_ccte(self,cr,uid,values):
274
290
"""Create a HRSelf CCTE.
275
@param values: Values
277
@return: identifier of created HRSelf CCTE
292
:param values: Values
294
:return: identifier of created HRSelf CCTE
279
296
return self._create_update_object_translation(cr, uid, None, 'hrself.ccte', values)
281
298
def update_hrself_ccte(self,cr,uid,id,values):
282
299
"""Update a HRSelf CCTE.
283
@param id: HRSelf CCTE identifier
285
@param values: Values
287
@return: True on sucess, False on failure
301
:param id: HRSelf CCTE identifier
303
:param values: Values
305
:return: True on sucess, False on failure
291
309
def read_hrself_ccte(self,cr,uid,employer_identifier,ccte_identifier):
292
310
"""Read a HRSelf CCTE identified in Groupe S by (employer_identifier, ccte_identifier).
293
@param employer_identifier: Groupe S employer identifier
294
@type employer_identifier: integer
295
@param ccte_identifier: Groupe S CCTE identifier
296
@type ccte_identifier: str
297
@return: Field values if HRSelf CCTE exists, False otherwise
298
@rtype: dict or boolean"""
312
:param employer_identifier: Groupe S employer identifier
313
:type employer_identifier: integer
314
:param ccte_identifier: Groupe S CCTE identifier
315
:type ccte_identifier: str
316
:return: Field values if HRSelf CCTE exists, False otherwise
317
:rtype: dict or boolean"""
299
318
employer_object = self.pool.get('hrself.employer')
300
319
employer_ids = employer_object.search(cr,uid,[('groupes_id', '=', employer_identifier)])
301
320
ccte_object = self.pool.get('hrself.ccte')
311
330
def create_hrself_level(self, cr, uid, values):
312
331
"""Create a HRSelf level.
313
@param values: Values
315
@return: identifier of created HRSelf level
333
:param values: Values
335
:return: identifier of created HRSelf level
317
337
return self._create_update_object_translation(cr, uid, None, 'hrself.level', values)
319
339
def update_hrself_level(self, cr, uid, id, values):
320
340
"""Update a HRSelf level.
321
@param id: HRSelf level identifier
323
@param values: Values
325
@return: True on sucess, False on failure
342
:param id: HRSelf level identifier
344
:param values: Values
346
:return: True on sucess, False on failure
327
348
return self._create_update_object_translation(cr, uid, id, 'hrself.level', values)
329
350
def read_hrself_level(self,cr,uid,employer_identifier,level_code, level_value):
330
351
"""Read a HRSelf level identified in Groupe S by (employer_identifier, level_code, level_value).
331
@param employer_identifier: Groupe S employer identifier
332
@type employer_identifier: integer
333
@param level_code: Groupe S level code
334
@type level_code: integer
335
@param level_value: Groupe S level value
336
@type level_value: integer
337
@return: Field values if HRSelf level exists, False otherwise
338
@rtype: dict or boolean"""
353
:param employer_identifier: Groupe S employer identifier
354
:type employer_identifier: integer
355
:param level_code: Groupe S level code
356
:type level_code: integer
357
:param level_value: Groupe S level value
358
:type level_value: integer
359
:return: Field values if HRSelf level exists, False otherwise
360
:rtype: dict or boolean"""
339
361
employer_object = self.pool.get('hrself.employer')
340
362
employer_ids = employer_object.search(cr,uid,[('groupes_id', '=', employer_identifier)])
341
363
level_object = self.pool.get('hrself.level')
351
373
def create_hrself_person(self, cr, uid, values):
352
374
"""Create a HRSelf person.
353
@param values: Values
355
@return: identifier of created HRSelf person
376
:param values: Values
378
:return: identifier of created HRSelf person
357
380
user_id = self._create_user(cr, uid, values)
358
381
values['user_id'] = user_id
359
382
employee_id = self._create_employee(cr, uid, self._hrself_person_values(cr, uid, values))
380
404
def _create_employee(self, cr, uid, values):
381
405
"""Create an employee.
382
@return: identifier of created employee
407
:return: identifier of created employee
384
409
employee_id = self.pool.get('hr.employee').create(cr, uid, values)
385
410
logger.info('hr.employee %d created' % employee_id)
386
411
return employee_id
388
413
def update_hrself_person(self, cr, uid, id, values):
389
414
"""Update a HRSelf person.
390
@param id: HRSelf person identifier
392
@param values: Values
394
@return: True on sucess, False on failure
416
:param id: HRSelf person identifier
418
:param values: Values
420
:return: True on sucess, False on failure
396
422
user_values = {'active': values['active']}
397
423
if 'context_lang' in values:
398
424
user_values['context_lang'] = values.pop('context_lang')
406
432
def _hrself_person_values(self, cr, uid, values):
407
433
"""OpenERP person values corresponding to Groupe S values.
408
@param values: Groupe S values
410
@return: OpenERP values
435
:param values: Groupe S values
437
:return: OpenERP values
412
439
result = dict(values)
413
440
if 'country_id' in values:
414
441
country_ids = self.pool.get('res.country').search(cr, uid, [('code', '=', values['country_id'])])
450
477
def search_hrself_person(self, cr, uid, universe_identifier, person_identifier):
451
478
"""Search a HRSelf person identified in Groupe S by (universe_identifier, person_identifier).
452
@param universe_identifier: Groupe S universe identifier
453
@type universe_identifier: integer
454
@param person_identifier: Groupe S person identifier
455
@type person_identifier: integer
456
@return: OpenERP Identifier if the person exists, False otherwise
457
@rtype: integer or boolean"""
480
:param universe_identifier: Groupe S universe identifier
481
:type universe_identifier: integer
482
:param person_identifier: Groupe S person identifier
483
:type person_identifier: integer
484
:return: OpenERP Identifier if the person exists, False otherwise
485
:rtype: integer or boolean"""
458
486
universe_ids = self.pool.get('hrself.universe').search(cr, uid, [('groupes_id', '=', universe_identifier)])
459
487
employee_ids = self.pool.get('hr.employee').search(cr, uid, [('universe_id', 'in', universe_ids), ('groupes_id', '=', person_identifier)])
465
493
def read_hrself_person(self, cr, uid, id):
466
494
"""Read a HRSelf person identified by id.
467
@precondition: the person identified by id exists
468
@return: Field values of the HRSelf person
496
:precondition: the person identified by id exists
497
:return: Field values of the HRSelf person
470
499
result = self.pool.get('hr.employee').read(cr, uid, id, [
471
500
'universe_id', 'user_id', 'marital', 'country_id', 'birthday', 'groupes_id',
472
501
'name', 'first_name', 'gender', 'active', 'work_email', 'home_email',
490
519
def create_hrself_activity_context(self, cr, uid, values):
491
520
"""Create a HRSelf activity context if it doesn't exists.
492
@param values: Values
494
@return: identifier of HRSelf activity context (created or existing)
522
:param values: Values
524
:return: identifier of HRSelf activity context (created or existing)
496
526
universe_id = self.pool.get('hrself.universe').search(cr,uid,[('groupes_id', '=', values['universe_id'])])[0]
497
527
employer_id = self.pool.get('hrself.employer').search(cr, uid, [('universe_id', '=', universe_id), ('groupes_id', '=', values['employer_id'])])[0]
498
528
ccte_id = self.pool.get('hrself.ccte').search(cr, uid, [('employer_id', '=', employer_id), ('groupes_id', '=', values['ccte_id'])])[0]
534
564
def read_hrself_activity_context(self, cr, uid, values):
535
565
"""Read a HRSelf activity context based on values.
536
@param values: values
538
@return: Field values if HRSelf activity context exists, False otherwise
539
@rtype: dict or boolean"""
567
:param values: values
569
:return: Field values if HRSelf activity context exists, False otherwise
570
:rtype: dict or boolean"""
540
571
universe_object = self.pool.get('hrself.universe')
541
572
universe_ids = universe_object.search(cr,uid,[('groupes_id', '=', values['universe_id'])])
542
573
employer_object = self.pool.get('hrself.employer')
573
604
def _create_update_object_translation(self, cr, uid, id, model_name, values):
574
605
"""Create or update a HRSelf object that has a translatable field.
576
608
- create: identifier of HRSelf object
579
@param model_name: the model name
580
@type model_name: str
581
@param values: Values
611
:param model_name: the model name
612
:type model_name: str
613
:param values: Values
584
616
- create: identifier of created HRSelf object
585
617
- update: True on success, False on failure
587
619
- create: integer
588
620
- update: bool"""
589
621
names = values.pop('name')
603
635
def _create_update_translations(self, cr, uid, id, model_name, source_name, names):
604
636
"""Create or update the translations associated to a model.
605
@param id: the model identifier
607
@param model_name: the model name
608
@type model_name: str
609
@param source_name: the source name for the translation
610
@type source_name: str
611
@param names: the translations
612
@type names: dict where the keys are the language and the value the translation in that language"""
638
:param id: the model identifier
640
:param model_name: the model name
641
:type model_name: str
642
:param source_name: the source name for the translation
643
:type source_name: str
644
:param names: the translations
645
:type names: dict where the keys are the language and the value the translation in that language"""
613
646
translation_object = self.pool.get('ir.translation')
614
647
for (key, value) in names.iteritems():
628
661
def _read_translations(self, cr, uid, ids, model_name):
629
662
"""Read the translations associated to a model.
630
@param ids: the model identifiers
631
@type ids: list of integer
632
@param model_name: the model name
633
@type model_name: str
634
@return: the translations
635
@rtype: dict where the keys are the language and the value the translation in that language"""
664
:param ids: the model identifiers
665
:type ids: list of integer
666
:param model_name: the model name
667
:type model_name: str
668
:return: the translations
669
:rtype: dict where the keys are the language and the value the translation in that language"""
636
670
translations = {}
637
671
translation_object = self.pool.get('ir.translation')
638
672
translation_ids = translation_object.search(cr,uid,[('name', '=', translation_object.name_for_model_type(model_name, 'name')),('type', '=', 'model'),('res_id', 'in', ids)])