Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odoo - Update for massive user creation script with new Odoo version #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions admin/crear_usuaris_odoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def create_employees(self, filename):
'firstname': employee_data['nom'].decode('utf8'),
'lastname': employee_data['cognoms'].decode('utf8'),
'login': employee_data['email'],
'groups_id': groups_id,
#'groups_id': groups_id,
'password': 'odoo',
'lang': 'ca_ES',
'tz': 'Europe/Andorra',
'sel_groups_1_9_10': 1,
#'tz': 'Europe/Madrid',
#'sel_groups_1_9_10': 1,
#Testing: 'action_id': 191, #Attendance fixar
'action_id': 557, #Attendance fixar
'action_id': 306, #Attendance fixar
'partner_id': partner_id
}
try:
Expand All @@ -110,9 +110,9 @@ def create_employees(self, filename):
except Exception as e:
msg = "I couldn\'t create a new user {}, reason {}"
warn(msg, user_data, e)
finally:
for group in groups_id:
O.ResGroups.write(group, {'users': [(4, user_id)]})
# finally:
# for group in groups_id:
# O.ResGroups.write(group, {'users': [(4, user_id)]})

# CREATE EMPLOYEE
# Get department id
Expand All @@ -123,17 +123,17 @@ def create_employees(self, filename):
# Get jornada
jornada_id = 1
if employee_data['jornada'] == '40':
jornada_id = O.IrModelData.get_object_reference('somenergia','resource_calendar_som_40h_partida')[1]
jornada_id = O.IrModelData.get_object_reference('somenergia_custom','resource_calendar_som_40h_partida')[1]
elif employee_data['jornada'] == '35':
jornada_id = O.IrModelData.get_object_reference('somenergia','resource_calendar_som_35h')[1]
jornada_id = O.IrModelData.get_object_reference('somenergia_custom','resource_calendar_som_35h')[1]
elif employee_data['jornada'] == '32':
jornada_id = O.IrModelData.get_object_reference('somenergia','resource_calendar_som_32h_dll_div')[1]
jornada_id = O.IrModelData.get_object_reference('somenergia_custom','resource_calendar_som_32h_dll_div')[1]
elif employee_data['jornada'] == '30':
jornada_id = O.IrModelData.get_object_reference('somenergia','resource_calendar_som_30h')[1]
jornada_id = O.IrModelData.get_object_reference('somenergia_custom','resource_calendar_som_30h')[1]
elif employee_data['jornada'] == '20':
jornada_id = O.IrModelData.get_object_reference('somenergia','resource_calendar_som_20h')[1]
jornada_id = O.IrModelData.get_object_reference('somenergia_custom','resource_calendar_som_20h')[1]
elif employee_data['jornada'] == '10':
jornada_id = O.IrModelData.get_object_reference('somenergia','resource_calendar_som_10h')[1]
jornada_id = O.IrModelData.get_object_reference('somenergia_custom','resource_calendar_som_10h')[1]

name = employee_data['cognoms'].decode('utf8') + ", " + employee_data['nom'].decode('utf8')
empleat_data = {
Expand All @@ -145,7 +145,7 @@ def create_employees(self, filename):
'user_id': user_id,
'resource_calendar_id': jornada_id,
#'birthday': datetime.strftime(datetime.strptime(employee_data['data_neixement'], "%d/%m/%Y"), "%Y-%m-%d"),
'theoretical_hours_start_date': '2021-05-01',
'theoretical_hours_start_date': '2024-01-01',
}
try:
if O.HrEmployee.search([('work_email','=',employee_data['email'])]):
Expand Down