Merge lp:~fabien-morin/unifield-web/fm-us-2925 into lp:unifield-web
- fm-us-2925
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 4883 |
Proposed branch: | lp:~fabien-morin/unifield-web/fm-us-2925 |
Merge into: | lp:unifield-web |
Diff against target: |
615 lines (+460/-5) 6 files modified
addons/openerp/controllers/database.py (+272/-3) addons/openerp/controllers/templates/auto_create.mako (+70/-0) addons/openerp/controllers/templates/auto_create_progress.mako (+80/-0) addons/openerp/controllers/utils.py (+12/-0) addons/openerp/po/messages/fr.po (+2/-2) addons/openerp/static/css/database.css (+24/-0) |
To merge this branch: | bzr merge lp:~fabien-morin/unifield-web/fm-us-2925 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email: mp+334060@code.launchpad.net |
Commit message
Description of the change
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 'addons/openerp/controllers/database.py' | |||
2 | --- addons/openerp/controllers/database.py 2017-07-11 12:19:46 +0000 | |||
3 | +++ addons/openerp/controllers/database.py 2017-11-21 17:05:56 +0000 | |||
4 | @@ -22,10 +22,12 @@ | |||
5 | 22 | import re | 22 | import re |
6 | 23 | import time | 23 | import time |
7 | 24 | import os | 24 | import os |
8 | 25 | import sys | ||
9 | 25 | 26 | ||
10 | 26 | import cherrypy | 27 | import cherrypy |
11 | 27 | import formencode | 28 | import formencode |
12 | 28 | 29 | ||
13 | 30 | from openobject import paths | ||
14 | 29 | from openobject.controllers import BaseController | 31 | from openobject.controllers import BaseController |
15 | 30 | from openobject.tools import url, expose, redirect, validate, error_handler | 32 | from openobject.tools import url, expose, redirect, validate, error_handler |
16 | 31 | import openobject | 33 | import openobject |
17 | @@ -35,6 +37,9 @@ | |||
18 | 35 | from openerp.utils import rpc, get_server_version, is_server_local, serve_file | 37 | from openerp.utils import rpc, get_server_version, is_server_local, serve_file |
19 | 36 | from tempfile import NamedTemporaryFile | 38 | from tempfile import NamedTemporaryFile |
20 | 37 | import shutil | 39 | import shutil |
21 | 40 | import ConfigParser | ||
22 | 41 | from ConfigParser import NoOptionError, NoSectionError | ||
23 | 42 | import threading | ||
24 | 38 | 43 | ||
25 | 39 | def get_lang_list(): | 44 | def get_lang_list(): |
26 | 40 | langs = [('en_US', 'English (US)')] | 45 | langs = [('en_US', 'English (US)')] |
27 | @@ -50,6 +55,8 @@ | |||
28 | 50 | except: | 55 | except: |
29 | 51 | return [] | 56 | return [] |
30 | 52 | 57 | ||
31 | 58 | class DatabaseExist(Exception): pass | ||
32 | 59 | |||
33 | 53 | class ReplacePasswordField(openobject.widgets.PasswordField): | 60 | class ReplacePasswordField(openobject.widgets.PasswordField): |
34 | 54 | params = { | 61 | params = { |
35 | 55 | 'autocomplete': 'Autocomplete field', | 62 | 'autocomplete': 'Autocomplete field', |
36 | @@ -116,6 +123,23 @@ | |||
37 | 116 | validator = openobject.validators.Schema(chained_validators=[formencode.validators.FieldsMatch("admin_password","confirm_password")]) | 123 | validator = openobject.validators.Schema(chained_validators=[formencode.validators.FieldsMatch("admin_password","confirm_password")]) |
38 | 117 | 124 | ||
39 | 118 | 125 | ||
40 | 126 | class FormAutoCreate(DBForm): | ||
41 | 127 | name = "auto_create" | ||
42 | 128 | string = _('Instance Auto Creation') | ||
43 | 129 | action = '/openerp/database/do_auto_create' | ||
44 | 130 | submit_text = _('Start auto creation') | ||
45 | 131 | #form_attrs = {'onsubmit': 'return window.confirm(_("Do you really want to drop the selected database?"))'} | ||
46 | 132 | fields = [ | ||
47 | 133 | ReplacePasswordField(name='password', label=_('Super admin password:')), | ||
48 | 134 | ] | ||
49 | 135 | |||
50 | 136 | |||
51 | 137 | class AutoCreateProgress(DBForm): | ||
52 | 138 | name = "get_auto_create_progress" | ||
53 | 139 | string = _('Auto Creation Progress') | ||
54 | 140 | action = '/openerp/database/get_auto_create_progress' | ||
55 | 141 | |||
56 | 142 | |||
57 | 119 | class FormDrop(DBForm): | 143 | class FormDrop(DBForm): |
58 | 120 | name = "drop" | 144 | name = "drop" |
59 | 121 | string = _('Drop database') | 145 | string = _('Drop database') |
60 | @@ -127,6 +151,7 @@ | |||
61 | 127 | ReplacePasswordField(name='password', label=_('Drop password:')), | 151 | ReplacePasswordField(name='password', label=_('Drop password:')), |
62 | 128 | ] | 152 | ] |
63 | 129 | 153 | ||
64 | 154 | |||
65 | 130 | class FormBackup(DBForm): | 155 | class FormBackup(DBForm): |
66 | 131 | name = "backup" | 156 | name = "backup" |
67 | 132 | string = _('Backup database') | 157 | string = _('Backup database') |
68 | @@ -137,10 +162,12 @@ | |||
69 | 137 | ReplacePasswordField(name='password', label=_('Backup password:')), | 162 | ReplacePasswordField(name='password', label=_('Backup password:')), |
70 | 138 | ] | 163 | ] |
71 | 139 | 164 | ||
72 | 165 | |||
73 | 140 | class FileField(openobject.widgets.FileField): | 166 | class FileField(openobject.widgets.FileField): |
74 | 141 | def adjust_value(self, value, **params): | 167 | def adjust_value(self, value, **params): |
75 | 142 | return False | 168 | return False |
76 | 143 | 169 | ||
77 | 170 | |||
78 | 144 | class FormRestore(DBForm): | 171 | class FormRestore(DBForm): |
79 | 145 | name = "restore" | 172 | name = "restore" |
80 | 146 | string = _('Restore database') | 173 | string = _('Restore database') |
81 | @@ -169,6 +196,7 @@ | |||
82 | 169 | 196 | ||
83 | 170 | 197 | ||
84 | 171 | _FORMS = { | 198 | _FORMS = { |
85 | 199 | 'auto_create': FormAutoCreate(), | ||
86 | 172 | 'create': FormCreate(), | 200 | 'create': FormCreate(), |
87 | 173 | 'drop': FormDrop(), | 201 | 'drop': FormDrop(), |
88 | 174 | 'backup': FormBackup(), | 202 | 'backup': FormBackup(), |
89 | @@ -176,9 +204,13 @@ | |||
90 | 176 | 'password': FormPassword() | 204 | 'password': FormPassword() |
91 | 177 | } | 205 | } |
92 | 178 | 206 | ||
93 | 207 | |||
94 | 179 | class DatabaseCreationError(Exception): pass | 208 | class DatabaseCreationError(Exception): pass |
95 | 209 | |||
96 | 210 | |||
97 | 180 | class DatabaseCreationCrash(DatabaseCreationError): pass | 211 | class DatabaseCreationCrash(DatabaseCreationError): pass |
98 | 181 | 212 | ||
99 | 213 | |||
100 | 182 | class Database(BaseController): | 214 | class Database(BaseController): |
101 | 183 | 215 | ||
102 | 184 | _cp_path = "/openerp/database" | 216 | _cp_path = "/openerp/database" |
103 | @@ -248,7 +280,7 @@ | |||
104 | 248 | break | 280 | break |
105 | 249 | else: | 281 | else: |
106 | 250 | time.sleep(1) | 282 | time.sleep(1) |
108 | 251 | except: | 283 | except Exception as e: |
109 | 252 | raise DatabaseCreationCrash() | 284 | raise DatabaseCreationCrash() |
110 | 253 | except DatabaseCreationCrash: | 285 | except DatabaseCreationCrash: |
111 | 254 | self.msg = {'message': (_("The server crashed during installation.\nWe suggest you to drop this database.")), | 286 | self.msg = {'message': (_("The server crashed during installation.\nWe suggest you to drop this database.")), |
112 | @@ -258,15 +290,252 @@ | |||
113 | 258 | self.msg = {'message': _('Bad super admin password'), | 290 | self.msg = {'message': _('Bad super admin password'), |
114 | 259 | 'title' : e.title} | 291 | 'title' : e.title} |
115 | 260 | return self.create() | 292 | return self.create() |
117 | 261 | except Exception: | 293 | except Exception as e: |
118 | 262 | self.msg = {'message':_("Could not create database.")} | 294 | self.msg = {'message':_("Could not create database.")} |
119 | 263 | |||
120 | 264 | return self.create() | 295 | return self.create() |
121 | 265 | 296 | ||
122 | 266 | if ok: | 297 | if ok: |
123 | 267 | raise redirect('/openerp/menu', {'next': '/openerp/home'}) | 298 | raise redirect('/openerp/menu', {'next': '/openerp/home'}) |
124 | 268 | raise redirect('/openerp/login', db=dbname) | 299 | raise redirect('/openerp/login', db=dbname) |
125 | 269 | 300 | ||
126 | 301 | @expose(template="/openerp/controllers/templates/auto_create.mako") | ||
127 | 302 | def auto_create(self, tg_errors=None, **kw): | ||
128 | 303 | form = _FORMS['auto_create'] | ||
129 | 304 | error = self.msg | ||
130 | 305 | self.msg = {} | ||
131 | 306 | return dict(form=form, error=error) | ||
132 | 307 | |||
133 | 308 | @expose() | ||
134 | 309 | def get_auto_create_progress(self, **kw): | ||
135 | 310 | config_file_name = 'uf_auto_install.conf' | ||
136 | 311 | if sys.platform == 'win32': | ||
137 | 312 | config_file_path = os.path.join(paths.root(), '..', 'UFautoInstall', config_file_name) | ||
138 | 313 | else: | ||
139 | 314 | config_file_path = os.path.join(paths.root(), '..', 'unifield-server', 'UFautoInstall', config_file_name) | ||
140 | 315 | if not os.path.exists(config_file_path): | ||
141 | 316 | return False | ||
142 | 317 | config = ConfigParser.ConfigParser() | ||
143 | 318 | config.read(config_file_path) | ||
144 | 319 | dbname = config.get('instance', 'db_name') | ||
145 | 320 | self.resume, self.progress, self.state, self.error, monitor_status = rpc.session.execute_db('creation_get_resume_progress', dbname) | ||
146 | 321 | my_dict = { | ||
147 | 322 | 'resume': self.resume, | ||
148 | 323 | 'progress': self.progress, | ||
149 | 324 | 'state': self.state, | ||
150 | 325 | 'error': self.error, | ||
151 | 326 | 'monitor_status': monitor_status, | ||
152 | 327 | } | ||
153 | 328 | import json | ||
154 | 329 | return json.dumps(my_dict) | ||
155 | 330 | |||
156 | 331 | @expose(template="/openerp/controllers/templates/auto_create_progress.mako") | ||
157 | 332 | def auto_create_progress(self, tg_errors=None, **kw): | ||
158 | 333 | finish = "" | ||
159 | 334 | finished = "False" | ||
160 | 335 | data_collected = "False" | ||
161 | 336 | return dict(finish=finish, percent=self.progress, resume=self.resume, total=finished, | ||
162 | 337 | data_collected=data_collected) | ||
163 | 338 | |||
164 | 339 | def check_not_empty_string(self, config, section, option): | ||
165 | 340 | if not config.has_option(section, option) or not config.get(section, option): | ||
166 | 341 | self.msg = {'message': ustr(_('The option \'%s\' from section \'[%s]\' cannot be empty, please set a value.') % (option, section)), | ||
167 | 342 | 'title': ustr(_('Empty option'))} | ||
168 | 343 | |||
169 | 344 | def check_mandatory_int(self, config, section, option): | ||
170 | 345 | try: | ||
171 | 346 | value = config.getint(section, option) | ||
172 | 347 | except ValueError: | ||
173 | 348 | self.msg = {'message': ustr(_('The option \'%s\' from section \'[%s]\' have to be a int.') % (option, section)), | ||
174 | 349 | 'title': ustr(_('Wrong option value'))} | ||
175 | 350 | return | ||
176 | 351 | if not value: | ||
177 | 352 | self.msg = {'message': ustr(_('The option \'%s\' from section \'[%s]\' cannot be empty, please set a value.') % (option, section)), | ||
178 | 353 | 'title': ustr(_('Empty option'))} | ||
179 | 354 | |||
180 | 355 | def check_possible_value(self, config, section, option, possible_values): | ||
181 | 356 | value = config.get(section, option) | ||
182 | 357 | if value not in possible_values: | ||
183 | 358 | self.msg = {'message': ustr(_('The option \'%s\' from section \'[%s]\' have to be one of those values: %r. (currently it is \'%s\').') % (option, section, possible_values, value)), | ||
184 | 359 | 'title': ustr(_('Wrong option'))} | ||
185 | 360 | |||
186 | 361 | def check_config_file(self, file_path): | ||
187 | 362 | ''' | ||
188 | 363 | perform some basic checks to avoid crashing later | ||
189 | 364 | ''' | ||
190 | 365 | if not os.path.exists(file_path): | ||
191 | 366 | self.msg = {'message': ustr(_("The auto creation config file '%s' does not exists.") % file_path), | ||
192 | 367 | 'title': ustr(_('Auto creation file not found'))} | ||
193 | 368 | |||
194 | 369 | config = ConfigParser.ConfigParser() | ||
195 | 370 | config.read(file_path) | ||
196 | 371 | try: | ||
197 | 372 | db_name = config.get('instance', 'db_name') | ||
198 | 373 | if not re.match('^[a-zA-Z][a-zA-Z0-9_-]+$', db_name): | ||
199 | 374 | self.msg = {'message': ustr(_("You must avoid all accents, space or special characters.")), | ||
200 | 375 | 'title': ustr(_('Bad database name'))} | ||
201 | 376 | return | ||
202 | 377 | |||
203 | 378 | admin_password = config.get('instance', 'admin_password') | ||
204 | 379 | res = rpc.session.execute_db('check_super_password_validity', admin_password) | ||
205 | 380 | if res is not True: | ||
206 | 381 | self.msg = {'message': res, | ||
207 | 382 | 'title': ustr(_('Bad admin password'))} | ||
208 | 383 | return | ||
209 | 384 | |||
210 | 385 | # check the mandatory string fields have a value | ||
211 | 386 | not_empty_string_option_list = ( | ||
212 | 387 | ('instance', 'oc'), | ||
213 | 388 | ('instance', 'admin_password'), | ||
214 | 389 | ('instance', 'sync_user'), | ||
215 | 390 | ('instance', 'sync_pwd'), | ||
216 | 391 | ('instance', 'instance_level'), | ||
217 | 392 | ('instance', 'parent_instance'), | ||
218 | 393 | ('instance', 'lang'), | ||
219 | 394 | ('backup', 'auto_bck_path'), | ||
220 | 395 | ('reconfigure', 'prop_instance_code'), | ||
221 | 396 | ('reconfigure', 'address_contact_name'), | ||
222 | 397 | ('reconfigure', 'address_street'), | ||
223 | 398 | ('reconfigure', 'address_street2'), | ||
224 | 399 | ('reconfigure', 'address_zip'), | ||
225 | 400 | ('reconfigure', 'address_city'), | ||
226 | 401 | ('reconfigure', 'address_country'), | ||
227 | 402 | ('reconfigure', 'address_phone'), | ||
228 | 403 | ('reconfigure', 'address_email'), | ||
229 | 404 | ('reconfigure', 'delivery_process'), | ||
230 | 405 | ('reconfigure', 'functional_currency'), | ||
231 | 406 | ) | ||
232 | 407 | for section, option in not_empty_string_option_list: | ||
233 | 408 | self.check_not_empty_string(config, section, option) | ||
234 | 409 | if self.msg: | ||
235 | 410 | return | ||
236 | 411 | |||
237 | 412 | # check mandatory integer values | ||
238 | 413 | not_empty_int_option_list = ( | ||
239 | 414 | ('backup', 'auto_bck_interval_nb'), | ||
240 | 415 | ('partner', 'external_account_receivable'), | ||
241 | 416 | ('partner', 'external_account_payable'), | ||
242 | 417 | ('partner', 'internal_account_receivable'), | ||
243 | 418 | ('partner', 'internal_account_payable'), | ||
244 | 419 | ('company', 'default_counterpart'), | ||
245 | 420 | ('company', 'salaries_default_account'), | ||
246 | 421 | ('company', 'rebilling_intersection_account'), | ||
247 | 422 | ('company', 'intermission_counterpart'), | ||
248 | 423 | ('company', 'counterpart_bs_debit_balance'), | ||
249 | 424 | ('company', 'counterpart_bs_crebit_balance'), | ||
250 | 425 | ('company', 'debit_account_pl_positive'), | ||
251 | 426 | ('company', 'credit_account_pl_negative'), | ||
252 | 427 | ('company', 'scheduler_range_days'), | ||
253 | 428 | ) | ||
254 | 429 | for section, option in not_empty_int_option_list: | ||
255 | 430 | self.check_mandatory_int(config, section, option) | ||
256 | 431 | if self.msg: | ||
257 | 432 | return | ||
258 | 433 | |||
259 | 434 | # check value is in possibles values | ||
260 | 435 | possible_value_list = ( | ||
261 | 436 | ('instance', 'instance_level', ('coordo', 'project')), | ||
262 | 437 | ('instance', 'lang', ('fr_MF', 'es_MF', 'en_MF')), | ||
263 | 438 | ('backup', 'auto_bck_interval_unit', ('minutes', 'hours', 'work_days', 'days', 'weeks', 'months')), | ||
264 | 439 | ('reconfigure', 'delivery_process', ('complex', 'simple')), | ||
265 | 440 | ) | ||
266 | 441 | |||
267 | 442 | for section, option, possible_values in possible_value_list: | ||
268 | 443 | self.check_possible_value(config, section, option, possible_values) | ||
269 | 444 | if self.msg: | ||
270 | 445 | return | ||
271 | 446 | |||
272 | 447 | except NoOptionError as e: | ||
273 | 448 | self.msg = {'message': ustr(_('No option \'%s\' found for the section \'[%s]\' in the config file \'%s\'') % (e.option, e.section, file_path)), | ||
274 | 449 | 'title': ustr(_('Option missing in configuration file'))} | ||
275 | 450 | return | ||
276 | 451 | except NoSectionError as e: | ||
277 | 452 | self.msg = {'message': ustr(_('No section \'%s\' found in the config file \'%s\'') % (e.section, file_path)), | ||
278 | 453 | 'title': ustr(_('Option missing in configuration file'))} | ||
279 | 454 | return | ||
280 | 455 | |||
281 | 456 | def database_creation(self, password, dbname, admin_password): | ||
282 | 457 | try: | ||
283 | 458 | res = rpc.session.execute_db('create', password, dbname, False, 'en_US', admin_password) | ||
284 | 459 | while True: | ||
285 | 460 | try: | ||
286 | 461 | progress, users = rpc.session.execute_db('get_progress', password, res) | ||
287 | 462 | if progress == 1.0: | ||
288 | 463 | for x in users: | ||
289 | 464 | if x['login'] == 'admin': | ||
290 | 465 | rpc.session.login(dbname, 'admin', x['password']) | ||
291 | 466 | ok = True | ||
292 | 467 | break | ||
293 | 468 | else: | ||
294 | 469 | time.sleep(1) | ||
295 | 470 | except Exception as e: | ||
296 | 471 | raise DatabaseCreationCrash() | ||
297 | 472 | except DatabaseCreationCrash: | ||
298 | 473 | self.msg = {'message': (_("The server crashed during installation.\nWe suggest you to drop this database.")), | ||
299 | 474 | 'title': (_('Error during database creation'))} | ||
300 | 475 | except openobject.errors.AccessDenied, e: | ||
301 | 476 | self.msg = {'message': _('Bad super admin password'), | ||
302 | 477 | 'title' : e.title} | ||
303 | 478 | |||
304 | 479 | def background_auto_creation(self, password, dbname, db_exists, config_dict): | ||
305 | 480 | if not db_exists: | ||
306 | 481 | # create database | ||
307 | 482 | self.database_creation(password, dbname, config_dict['instance'].get('admin_password')) | ||
308 | 483 | |||
309 | 484 | rpc.session.execute_db('instance_auto_creation', password, dbname) | ||
310 | 485 | self.resume, self.progress, self.state, self.error, monitor_status = rpc.session.execute_db('creation_get_resume_progress', dbname) | ||
311 | 486 | |||
312 | 487 | @expose() | ||
313 | 488 | @validate(form=_FORMS['auto_create']) | ||
314 | 489 | @error_handler(auto_create) | ||
315 | 490 | def do_auto_create(self, password, **kw): | ||
316 | 491 | self.msg = {} | ||
317 | 492 | self.progress = 0.03 | ||
318 | 493 | self.state = 'draft' | ||
319 | 494 | try: | ||
320 | 495 | config_file_name = 'uf_auto_install.conf' | ||
321 | 496 | if sys.platform == 'win32': | ||
322 | 497 | config_file_path = os.path.join(paths.root(), '..', 'UFautoInstall', config_file_name) | ||
323 | 498 | else: | ||
324 | 499 | config_file_path = os.path.join(paths.root(), '..', 'unifield-server', 'UFautoInstall', config_file_name) | ||
325 | 500 | |||
326 | 501 | self.check_config_file(config_file_path) | ||
327 | 502 | if self.msg: | ||
328 | 503 | return self.auto_create() | ||
329 | 504 | config = ConfigParser.ConfigParser() | ||
330 | 505 | config.read(config_file_path) | ||
331 | 506 | |||
332 | 507 | config_dict = {x:dict(config.items(x)) for x in config.sections()} | ||
333 | 508 | dbname = config_dict['instance'].get('db_name') | ||
334 | 509 | db_exists = False | ||
335 | 510 | |||
336 | 511 | # check the database not already exists | ||
337 | 512 | if dbname in get_db_list(): | ||
338 | 513 | db_exists = True | ||
339 | 514 | self.resume = _('Database with this name exists, resume from the last point...\n') | ||
340 | 515 | else: | ||
341 | 516 | self.resume = _('Empty database creation in progress...\n') | ||
342 | 517 | #raise DatabaseExist | ||
343 | 518 | |||
344 | 519 | create_thread = threading.Thread(target=self.background_auto_creation, | ||
345 | 520 | args=(password, dbname, db_exists, | ||
346 | 521 | config_dict)) | ||
347 | 522 | create_thread.start() | ||
348 | 523 | create_thread.join(0.5) | ||
349 | 524 | |||
350 | 525 | except openobject.errors.AccessDenied, e: | ||
351 | 526 | self.msg = {'message': _('Wrong password'), | ||
352 | 527 | 'title' : e.title} | ||
353 | 528 | except DatabaseExist: | ||
354 | 529 | pass | ||
355 | 530 | #self.msg = {'message': ustr(_('The database already exist')), | ||
356 | 531 | # 'title': 'Database exist'} | ||
357 | 532 | except Exception as e: | ||
358 | 533 | self.msg = {'message' : _("Could not auto create database: %s") % e} | ||
359 | 534 | |||
360 | 535 | if self.msg: | ||
361 | 536 | return self.auto_create() | ||
362 | 537 | return self.auto_create_progress() | ||
363 | 538 | |||
364 | 270 | @expose(template="/openerp/controllers/templates/database.mako") | 539 | @expose(template="/openerp/controllers/templates/database.mako") |
365 | 271 | def drop(self, tg_errors=None, **kw): | 540 | def drop(self, tg_errors=None, **kw): |
366 | 272 | form = _FORMS['drop'] | 541 | form = _FORMS['drop'] |
367 | 273 | 542 | ||
368 | === added file 'addons/openerp/controllers/templates/auto_create.mako' | |||
369 | --- addons/openerp/controllers/templates/auto_create.mako 1970-01-01 00:00:00 +0000 | |||
370 | +++ addons/openerp/controllers/templates/auto_create.mako 2017-11-21 17:05:56 +0000 | |||
371 | @@ -0,0 +1,70 @@ | |||
372 | 1 | <%inherit file="/openerp/controllers/templates/base_dispatch.mako"/> | ||
373 | 2 | <%def name="current_for(name)"><% | ||
374 | 3 | if form.name == name: context.write('current') | ||
375 | 4 | %></%def> | ||
376 | 5 | <%def name="header()"> | ||
377 | 6 | <title>${form.string}</title> | ||
378 | 7 | |||
379 | 8 | <script type="text/javascript" src="/openerp/static/javascript/openerp/openerp.ui.waitbox.js"></script> | ||
380 | 9 | <link rel="stylesheet" type="text/css" href="/openerp/static/css/waitbox.css"/> | ||
381 | 10 | <link rel="stylesheet" type="text/css" href="/openerp/static/css/database.css"/> | ||
382 | 11 | <script type="text/javascript"> | ||
383 | 12 | function on_create() { | ||
384 | 13 | new openerp.ui.WaitBox().showAfter(2000); | ||
385 | 14 | return true; | ||
386 | 15 | } | ||
387 | 16 | </script> | ||
388 | 17 | % if error: | ||
389 | 18 | <script type="text/javascript"> | ||
390 | 19 | var $error_tbl = jQuery('<table class="errorbox">'); | ||
391 | 20 | $error_tbl.append('<tr><td style="padding: 4px 2px;" width="10%"><img src="/openerp/static/images/warning.png"></td><td class="error_message_content">${error["message"]}</td></tr>'); | ||
392 | 21 | $error_tbl.append('<tr><td style="padding: 0 8px 5px 0; vertical-align:top;" align="right" colspan="2"><a class="button-a" id="error_btn" onclick="$error_tbl.dialog(\'close\');">OK</a></td></tr>'); | ||
393 | 22 | |||
394 | 23 | jQuery(document).ready(function () { | ||
395 | 24 | jQuery(document.body).append($error_tbl); | ||
396 | 25 | var error_dialog_options = { | ||
397 | 26 | modal: true, | ||
398 | 27 | resizable: false, | ||
399 | 28 | title: '<div class="error_message_header">${error.get("title", "Warning")}</div>' | ||
400 | 29 | }; | ||
401 | 30 | % if error.get('redirect_to'): | ||
402 | 31 | error_dialog_options['close'] = function( event, ui ) { | ||
403 | 32 | $(location).attr('href','${error['redirect_to']}'); | ||
404 | 33 | }; | ||
405 | 34 | % endif | ||
406 | 35 | $error_tbl.dialog(error_dialog_options); | ||
407 | 36 | }) | ||
408 | 37 | </script> | ||
409 | 38 | % endif | ||
410 | 39 | </%def> | ||
411 | 40 | |||
412 | 41 | <%def name="content()"> | ||
413 | 42 | <table width="100%"> | ||
414 | 43 | <tr><%include file="header.mako"/></tr> | ||
415 | 44 | </table> | ||
416 | 45 | <div class="db-form"> | ||
417 | 46 | <h1>Automated instance creation detected</h1> | ||
418 | 47 | |||
419 | 48 | <div class='auto_instance_text'> | ||
420 | 49 | <p>If you have checked the following points, you can start the | ||
421 | 50 | process of instance auto creation by login with the Super admin password. Points to check: | ||
422 | 51 | <ul> | ||
423 | 52 | <li>A Folder 'UFautoInstall' is present in Unifield/Server folder.</li> | ||
424 | 53 | <li>This folder contain a file 'uf_auto_install.conf'</li> | ||
425 | 54 | <li>This file is correct (required fields, correct values)</li> | ||
426 | 55 | <li>The folder also contain an 'import' directory | ||
427 | 56 | (Unifield/Server/UFautoInstall/import)</li> | ||
428 | 57 | <li>This 'import' directory contain files where the name of | ||
429 | 58 | the file is the model to import and the extension is csv (typically, | ||
430 | 59 | 'account.analytic.journal.csv' and 'account.journal.csv')</li> | ||
431 | 60 | <li>The connexion to the SYNC_SERVER is ok (credentials, | ||
432 | 61 | address, port, ...)</li> | ||
433 | 62 | <li>The parents instance (HQ, and Coordo if it is a | ||
434 | 63 | project) exists and are present as instance in the SYNC_SERVER</li> | ||
435 | 64 | </ul> | ||
436 | 65 | </p> | ||
437 | 66 | </div> | ||
438 | 67 | <div>${form.display()}</div> | ||
439 | 68 | </div> | ||
440 | 69 | <%include file="footer.mako"/> | ||
441 | 70 | </%def> | ||
442 | 0 | 71 | ||
443 | === added file 'addons/openerp/controllers/templates/auto_create_progress.mako' | |||
444 | --- addons/openerp/controllers/templates/auto_create_progress.mako 1970-01-01 00:00:00 +0000 | |||
445 | +++ addons/openerp/controllers/templates/auto_create_progress.mako 2017-11-21 17:05:56 +0000 | |||
446 | @@ -0,0 +1,80 @@ | |||
447 | 1 | <%inherit file="/openerp/controllers/templates/base_dispatch.mako"/> | ||
448 | 2 | <%def name="header()"> | ||
449 | 3 | <title>Instance creation progression</title> | ||
450 | 4 | |||
451 | 5 | <script type="text/javascript" src="/openerp/static/javascript/openerp/openerp.ui.waitbox.js"></script> | ||
452 | 6 | <script type="text/javascript"> | ||
453 | 7 | $(document).ready(function(){ | ||
454 | 8 | interval = setInterval(function() | ||
455 | 9 | { | ||
456 | 10 | $.ajax({ | ||
457 | 11 | type: 'get', | ||
458 | 12 | dataType: "json", | ||
459 | 13 | url: 'get_auto_create_progress', | ||
460 | 14 | success: function (data) { | ||
461 | 15 | |||
462 | 16 | if (data){ | ||
463 | 17 | if (data.error){ | ||
464 | 18 | clearInterval(interval); | ||
465 | 19 | var $error_tbl = jQuery('<table class="errorbox">'); | ||
466 | 20 | $error_tbl.append('<tr><td style="padding: 4px 2px;" width="10%"><img src="/openerp/static/images/warning.png"></td><td class="error_message_content">' + data.error + '</td></tr>'); | ||
467 | 21 | $error_tbl.append('<tr><td style="padding: 0 8px 5px 0; vertical-align:top;" align="right" colspan="2"><a class="button-a" id="error_btn" onclick="$error_tbl.dialog(\'close\');">OK</a></td></tr>'); | ||
468 | 22 | |||
469 | 23 | jQuery(document).ready(function () { | ||
470 | 24 | jQuery(document.body).append($error_tbl); | ||
471 | 25 | var error_dialog_options = { | ||
472 | 26 | modal: true, | ||
473 | 27 | resizable: false, | ||
474 | 28 | title: '<div class="error_message_header">Error</div>' | ||
475 | 29 | }; | ||
476 | 30 | $error_tbl.dialog(error_dialog_options); | ||
477 | 31 | }) | ||
478 | 32 | |||
479 | 33 | }; | ||
480 | 34 | $("div.auto_creation_resume textarea").val(data.resume); | ||
481 | 35 | $("div.progressbar").text((data.progress*100).toPrecision(3)+'%'); | ||
482 | 36 | $("div.progressbar").css({"width":(data.progress*100).toPrecision(3)+'%'}); | ||
483 | 37 | $("div.my_state").text(data.state); | ||
484 | 38 | if (data.state === 'done') { | ||
485 | 39 | clearInterval(interval); | ||
486 | 40 | }; | ||
487 | 41 | if (data.monitor_status) { | ||
488 | 42 | $("div.my_monitor_status").text(data.monitor_status); | ||
489 | 43 | }; | ||
490 | 44 | } | ||
491 | 45 | }, | ||
492 | 46 | error: function (xhr, status, error) { | ||
493 | 47 | } | ||
494 | 48 | }); | ||
495 | 49 | }, 3000) | ||
496 | 50 | }); | ||
497 | 51 | </script> | ||
498 | 52 | |||
499 | 53 | <link rel="stylesheet" type="text/css" href="/openerp/static/css/waitbox.css"/> | ||
500 | 54 | <link rel="stylesheet" type="text/css" href="/openerp/static/css/database.css"/> | ||
501 | 55 | |||
502 | 56 | </%def> | ||
503 | 57 | |||
504 | 58 | <%def name="content()"> | ||
505 | 59 | <table width="100%"> | ||
506 | 60 | <tr><%include file="header.mako"/></tr> | ||
507 | 61 | </table> | ||
508 | 62 | |||
509 | 63 | |||
510 | 64 | |||
511 | 65 | <div class="db-form"> | ||
512 | 66 | <h1>Automated instance creation in progress...</h1> | ||
513 | 67 | |||
514 | 68 | <div class="my_state"></div> | ||
515 | 69 | <div class="my_monitor_status"></div> | ||
516 | 70 | |||
517 | 71 | <div class="instance_creation_progress"> | ||
518 | 72 | <div class="progressbar" style="width:${'%d'%(percent*100)}%">${'%d'%(percent*100)}%</div> | ||
519 | 73 | </div> | ||
520 | 74 | |||
521 | 75 | <div class="auto_creation_resume"> | ||
522 | 76 | <textarea rows="20" cols="80">${resume}</textarea> | ||
523 | 77 | </div> | ||
524 | 78 | </div> | ||
525 | 79 | <%include file="footer.mako"/> | ||
526 | 80 | </%def> | ||
527 | 0 | 81 | ||
528 | === modified file 'addons/openerp/controllers/utils.py' | |||
529 | --- addons/openerp/controllers/utils.py 2016-11-17 15:29:41 +0000 | |||
530 | +++ addons/openerp/controllers/utils.py 2017-11-21 17:05:56 +0000 | |||
531 | @@ -20,11 +20,13 @@ | |||
532 | 20 | ############################################################################### | 20 | ############################################################################### |
533 | 21 | import re | 21 | import re |
534 | 22 | import os | 22 | import os |
535 | 23 | import sys | ||
536 | 23 | 24 | ||
537 | 24 | import cherrypy | 25 | import cherrypy |
538 | 25 | from openerp.utils import rpc | 26 | from openerp.utils import rpc |
539 | 26 | 27 | ||
540 | 27 | from openobject import tools | 28 | from openobject import tools |
541 | 29 | from openobject import paths | ||
542 | 28 | from openobject.tools import expose, redirect | 30 | from openobject.tools import expose, redirect |
543 | 29 | import openobject | 31 | import openobject |
544 | 30 | 32 | ||
545 | @@ -94,6 +96,16 @@ | |||
546 | 94 | url = rpc.session.connection_string | 96 | url = rpc.session.connection_string |
547 | 95 | url = str(url[:-1]) | 97 | url = str(url[:-1]) |
548 | 96 | 98 | ||
549 | 99 | config_file_name = 'uf_auto_install.conf' | ||
550 | 100 | if sys.platform == 'win32': | ||
551 | 101 | config_file_path = os.path.join(paths.root(), '..', 'UFautoInstall', config_file_name) | ||
552 | 102 | else: | ||
553 | 103 | config_file_path = os.path.join(paths.root(), '..', 'unifield-server', 'UFautoInstall', config_file_name) | ||
554 | 104 | if os.path.exists(config_file_path): | ||
555 | 105 | raise redirect('/openerp/database/auto_create') | ||
556 | 106 | return auto_install(target, db, user, password, action, message, | ||
557 | 107 | origArgs, url) | ||
558 | 108 | |||
559 | 97 | result = get_db_list() | 109 | result = get_db_list() |
560 | 98 | dblist = result['dblist'] | 110 | dblist = result['dblist'] |
561 | 99 | bad_regional = result['bad_regional'] | 111 | bad_regional = result['bad_regional'] |
562 | 100 | 112 | ||
563 | === modified file 'addons/openerp/po/messages/fr.po' | |||
564 | --- addons/openerp/po/messages/fr.po 2017-10-27 14:32:19 +0000 | |||
565 | +++ addons/openerp/po/messages/fr.po 2017-11-21 17:05:56 +0000 | |||
566 | @@ -275,7 +275,7 @@ | |||
567 | 275 | 275 | ||
568 | 276 | #: controllers/database.py:173 | 276 | #: controllers/database.py:173 |
569 | 277 | msgid "You must avoid all accents, space or special characters." | 277 | msgid "You must avoid all accents, space or special characters." |
571 | 278 | msgstr "Les accents , espaces et caractères spéciaux ne sont pas autorisés ." | 278 | msgstr "Les accents, espaces et caractères spéciaux ne sont pas autorisés ." |
572 | 279 | 279 | ||
573 | 280 | #: controllers/database.py:174 | 280 | #: controllers/database.py:174 |
574 | 281 | msgid "Bad database name" | 281 | msgid "Bad database name" |
575 | @@ -648,7 +648,7 @@ | |||
576 | 648 | "données. Il met en relation, améliore et\n" | 648 | "données. Il met en relation, améliore et\n" |
577 | 649 | " gère les processus dans les domaines des ventes, de la " | 649 | " gère les processus dans les domaines des ventes, de la " |
578 | 650 | "finance, de la logistique,\n" | 650 | "finance, de la logistique,\n" |
580 | 651 | " de la gestion de projets , la production, les services, " | 651 | " de la gestion de projets, la production, les services, " |
581 | 652 | "la gestion de la relation client, etc.\n" | 652 | "la gestion de la relation client, etc.\n" |
582 | 653 | " " | 653 | " " |
583 | 654 | 654 | ||
584 | 655 | 655 | ||
585 | === modified file 'addons/openerp/static/css/database.css' | |||
586 | --- addons/openerp/static/css/database.css 2012-11-15 08:31:02 +0000 | |||
587 | +++ addons/openerp/static/css/database.css 2017-11-21 17:05:56 +0000 | |||
588 | @@ -69,3 +69,27 @@ | |||
589 | 69 | text-align: right; | 69 | text-align: right; |
590 | 70 | padding: 0 5px 0 0; | 70 | padding: 0 5px 0 0; |
591 | 71 | } | 71 | } |
592 | 72 | |||
593 | 73 | .instance_creation_progress { | ||
594 | 74 | width: 20%; | ||
595 | 75 | margin-left: 40%; | ||
596 | 76 | margin-top: 2em; | ||
597 | 77 | margin-bottom: 2em; | ||
598 | 78 | border: solid 1px lightslategrey; | ||
599 | 79 | } | ||
600 | 80 | |||
601 | 81 | .instance_creation_progress .progressbar { | ||
602 | 82 | background-color: #4CAF50; | ||
603 | 83 | text-align: center; | ||
604 | 84 | font-size: 15px; | ||
605 | 85 | line-height: 2; | ||
606 | 86 | } | ||
607 | 87 | |||
608 | 88 | .auto_creation_resume { | ||
609 | 89 | text-align: center; | ||
610 | 90 | } | ||
611 | 91 | |||
612 | 92 | .auto_instance_text { | ||
613 | 93 | font-size: 1.5em; | ||
614 | 94 | margin: 3em; | ||
615 | 95 | } |