[IMP] ir_confir_parameter: add parameter 'force' in method 'init' to reinitialize existing parameters
This is useful when creating a new database from a dump (reinitialize database.uuid, etc.) bzr revid: rco@openerp.com-20121119110206-la2yaohf7wmi9yx2
This commit is contained in:
parent
248f81277f
commit
6bbac26ffb
|
@ -51,12 +51,14 @@ class ir_config_parameter(osv.osv):
|
|||
('key_uniq', 'unique (key)', 'Key must be unique.')
|
||||
]
|
||||
|
||||
def init(self, cr):
|
||||
def init(self, cr, force=False):
|
||||
"""
|
||||
Initializes the parameters listed in _default_parameters.
|
||||
It overrides existing parameters if force is ``True``.
|
||||
"""
|
||||
for key, func in _default_parameters.iteritems():
|
||||
ids = self.search(cr, SUPERUSER_ID, [('key','=',key)])
|
||||
# force=True skips search and always performs the 'if' body (because ids=False)
|
||||
ids = not force and self.search(cr, SUPERUSER_ID, [('key','=',key)])
|
||||
if not ids:
|
||||
self.set_param(cr, SUPERUSER_ID, key, func())
|
||||
|
||||
|
|
Loading…
Reference in New Issue