Merge lp:~jfb-tempo-consulting/unifield-web/US-6032 into lp:unifield-web

Proposed by jftempo
Status: Merged
Merged at revision: 4969
Proposed branch: lp:~jfb-tempo-consulting/unifield-web/US-6032
Merge into: lp:unifield-web
Diff against target: 129 lines (+77/-0)
1 file modified
addons/openerp/controllers/database.py (+77/-0)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-web/US-6032
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+370757@code.launchpad.net
To post a comment you must log in.
4971. By jftempo

Auto instance create if auto patch true, check that auto sync is true

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/openerp/controllers/database.py'
--- addons/openerp/controllers/database.py 2019-05-23 08:14:46 +0000
+++ addons/openerp/controllers/database.py 2019-08-08 15:43:48 +0000
@@ -41,6 +41,7 @@
41from ConfigParser import NoOptionError, NoSectionError41from ConfigParser import NoOptionError, NoSectionError
42import threading42import threading
4343
44TRUE_LIST = (True, 'True', 'true', 'TRUE', 'Yes', 'YES', 'yes')
44def get_lang_list():45def get_lang_list():
45 langs = [('en_US', 'English (US)')]46 langs = [('en_US', 'English (US)')]
46 try:47 try:
@@ -358,6 +359,27 @@
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)),359 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)),
359 'title': ustr(_('Wrong option'))}360 'title': ustr(_('Wrong option'))}
360361
362 def check_date_time(self, config, section, option, time_format):
363 if not config.has_option(section, option):
364 return True
365 value = config.get(section, option)
366 if value:
367 try:
368 time.strptime(value, time_format)
369 except:
370 return False
371 return True
372
373 def check_datetime(self, config, section, option):
374 if not self.check_date_time(config, section, option, '%Y-%m-%d %H:%M'):
375 self.msg = {'message': ustr(_('The option \'%s\' from section \'[%s]\' datetime format expected YYY-MM-DD HH:MM') % (option, section)),
376 'title': ustr(_('Wrong format'))}
377
378 def check_time(self, config, section, option):
379 if not self.check_date_time(config, section, option, '%H:%M'):
380 self.msg = {'message': ustr(_('The option \'%s\' from section \'[%s]\' time format expected HH:MM') % (option, section)),
381 'title': ustr(_('Wrong format'))}
382
361 def check_config_file(self, file_path):383 def check_config_file(self, file_path):
362 '''384 '''
363 perform some basic checks to avoid crashing later385 perform some basic checks to avoid crashing later
@@ -416,6 +438,8 @@
416 ('partner', 'external_account_payable'),438 ('partner', 'external_account_payable'),
417 ('partner', 'internal_account_receivable'),439 ('partner', 'internal_account_receivable'),
418 ('partner', 'internal_account_payable'),440 ('partner', 'internal_account_payable'),
441 ('autosync', 'interval_nb'),
442 ('stockmission', 'interval_nb'),
419 )443 )
420 for section, option in not_empty_int_option_list:444 for section, option in not_empty_int_option_list:
421 self.check_mandatory_int(config, section, option)445 self.check_mandatory_int(config, section, option)
@@ -427,6 +451,8 @@
427 ('instance', 'instance_level', ('coordo', 'project')),451 ('instance', 'instance_level', ('coordo', 'project')),
428 ('instance', 'lang', ('fr_MF', 'es_MF', 'en_MF')),452 ('instance', 'lang', ('fr_MF', 'es_MF', 'en_MF')),
429 ('backup', 'auto_bck_interval_unit', ('minutes', 'hours', 'work_days', 'days', 'weeks', 'months')),453 ('backup', 'auto_bck_interval_unit', ('minutes', 'hours', 'work_days', 'days', 'weeks', 'months')),
454 ('autosync', 'interval_unit', ('minutes', 'hours', 'work_days', 'days', 'weeks', 'months')),
455 ('stockmission', 'interval_unit', ('minutes', 'hours', 'work_days', 'days', 'weeks', 'months')),
430 ('reconfigure', 'delivery_process', ('complex', 'simple')),456 ('reconfigure', 'delivery_process', ('complex', 'simple')),
431 )457 )
432 for section, option, possible_values in possible_value_list:458 for section, option, possible_values in possible_value_list:
@@ -434,6 +460,19 @@
434 if self.msg:460 if self.msg:
435 return461 return
436462
463 check_format = [
464 ('backup', 'auto_bck_next_exec_date', self.check_datetime),
465 ('autosync', 'next_exec_date', self.check_datetime),
466 ('stockmission', 'next_exec_date', self.check_datetime),
467 ('silentupgrade', 'hour_from', self.check_time),
468 ('silentupgrade', 'hour_to', self.check_time),
469
470 ]
471 for section, option, check_fct in check_format:
472 check_fct(config, section, option)
473 if self.msg:
474 return
475
437 if config.get('instance', 'instance_level') == 'project':476 if config.get('instance', 'instance_level') == 'project':
438 if len(config.get('instance', 'group_names').split(',')) != 3:477 if len(config.get('instance', 'group_names').split(',')) != 3:
439 self.msg = {478 self.msg = {
@@ -462,6 +501,27 @@
462 }501 }
463 return502 return
464503
504 # silent uprade True only if autosync True
505 if (not config.has_option('silentupgrade', 'active') or config.get('silentupgrade', 'active') in TRUE_LIST) and config.has_option('autosync', 'active') and config.get('autosync', 'active') not in TRUE_LIST:
506 self.msg = {
507 'message': _('Silent Upgrade active value and Autosync active value are not consistent '),
508 'title': _('Auto sync / silent upgrade'),
509 }
510 return
511
512 # check date betweens auto patch and sync scheduler
513 if config.has_option('autosync', 'next_exec_date') and config.has_option('silentupgrade', 'hour_to') and config.has_option('silentupgrade', 'hour_from'):
514 if (not config.has_option('autosync', 'active') or config.get('autosync', 'active') in TRUE_LIST) and (not config.has_option('silentupgrade', 'active') or config.get('silentupgrade', 'active') in TRUE_LIST):
515 time_from = time.strptime(config.get('silentupgrade', 'hour_from'), '%H:%M')
516 time_to = time.strptime(config.get('silentupgrade', 'hour_to'), '%H:%M')
517 if not server_rpc.execute('object', 'execute', 'sync.client.sync_server_connection', 'is_automatic_patching_allowed',
518 config.get('autosync', 'next_exec_date'), True, time_from.tm_hour + time_from.tm_min/60. , time_to.tm_hour + time_to.tm_min/60.
519 ):
520 self.msg = {
521 'message': _('"Scheduler autosync next date" and "Silent Upgrade interval" are not consistent'),
522 'title': _('Auto sync / silent upgrade'),
523 }
524 return
465 config_groups = config.get('instance', 'group_names').split(',')525 config_groups = config.get('instance', 'group_names').split(',')
466 found_group = []526 found_group = []
467 groups_ids = server_rpc.execute('object', 'execute', 'sync.server.entity_group', 'search', [('name', 'in', config_groups)])527 groups_ids = server_rpc.execute('object', 'execute', 'sync.server.entity_group', 'search', [('name', 'in', config_groups)])
@@ -495,6 +555,23 @@
495 }555 }
496 return556 return
497557
558 import_path = os.path.join(os.path.dirname(file_path), 'import')
559 if os.path.exists(import_path):
560 for file_name in os.listdir(import_path):
561 if not file_name.endswith('.csv'):
562 self.msg = {
563 'message': 'File to import %s: incorrect name (must end with .csv:' % file_name,
564 'title': 'File name error',
565 }
566 return
567 import_object = file_name.split('.csv')[0]
568 if not server_rpc.execute('object', 'execute', 'ir.model', 'search', [('model', '=', import_object)]):
569 self.msg = {
570 'message': 'File to import %s: incorrect name object %s does not exist' % (file_name, import_object),
571 'title': 'File name error',
572 }
573 return
574
498575
499 except NoOptionError as e:576 except NoOptionError as e:
500 self.msg = {'message': ustr(_('No option \'%s\' found for the section \'[%s]\' in the config file \'%s\'') % (e.option, e.section, file_path)),577 self.msg = {'message': ustr(_('No option \'%s\' found for the section \'[%s]\' in the config file \'%s\'') % (e.option, e.section, file_path)),

Subscribers

People subscribed via source and target branches