[REF] no longer use openerp.pooler.
Either use openerp.modules.registry.RegistryManager when the full new() signature is needed, or use openerp.registry(). Replaced also some pool.get() with pool[] because KeyErrors are better than AttributeErrors on None. bzr revid: vmt@openerp.com-20130327111014-2i0hlvpy5y5ku7hm
This commit is contained in:
parent
684bd35442
commit
1e7e2ca753
|
@ -123,7 +123,7 @@ class ir_cron(osv.osv):
|
||||||
try:
|
try:
|
||||||
args = str2tuple(args)
|
args = str2tuple(args)
|
||||||
openerp.modules.registry.RegistryManager.check_registry_signaling(cr.dbname)
|
openerp.modules.registry.RegistryManager.check_registry_signaling(cr.dbname)
|
||||||
registry = openerp.pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
model = registry.get(model_name)
|
model = registry.get(model_name)
|
||||||
if model and hasattr(model, method_name):
|
if model and hasattr(model, method_name):
|
||||||
method = getattr(model, method_name)
|
method = getattr(model, method_name)
|
||||||
|
@ -223,7 +223,7 @@ class ir_cron(osv.osv):
|
||||||
_logger.debug('Starting job `%s`.', job['name'])
|
_logger.debug('Starting job `%s`.', job['name'])
|
||||||
job_cr = db.cursor()
|
job_cr = db.cursor()
|
||||||
try:
|
try:
|
||||||
registry = openerp.pooler.get_pool(db_name)
|
registry = openerp.registry(db_name)
|
||||||
registry[cls._name]._process_job(job_cr, job, lock_cr)
|
registry[cls._name]._process_job(job_cr, job, lock_cr)
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.exception('Unexpected exception while processing cron job %r', job)
|
_logger.exception('Unexpected exception while processing cron job %r', job)
|
||||||
|
|
|
@ -26,7 +26,7 @@ import types
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
from openerp import netsvc, pooler, tools
|
from openerp import netsvc, tools
|
||||||
from openerp.osv import fields,osv
|
from openerp.osv import fields,osv
|
||||||
from openerp.osv.orm import Model
|
from openerp.osv.orm import Model
|
||||||
from openerp.tools.safe_eval import safe_eval as eval
|
from openerp.tools.safe_eval import safe_eval as eval
|
||||||
|
@ -50,7 +50,7 @@ def _get_fields_type(self, cr, uid, context=None):
|
||||||
|
|
||||||
def _in_modules(self, cr, uid, ids, field_name, arg, context=None):
|
def _in_modules(self, cr, uid, ids, field_name, arg, context=None):
|
||||||
#pseudo-method used by fields.function in ir.model/ir.model.fields
|
#pseudo-method used by fields.function in ir.model/ir.model.fields
|
||||||
module_pool = self.pool.get("ir.module.module")
|
module_pool = self.pool["ir.module.module"]
|
||||||
installed_module_ids = module_pool.search(cr, uid, [('state','=','installed')])
|
installed_module_ids = module_pool.search(cr, uid, [('state','=','installed')])
|
||||||
installed_module_names = module_pool.read(cr, uid, installed_module_ids, ['name'], context=context)
|
installed_module_names = module_pool.read(cr, uid, installed_module_ids, ['name'], context=context)
|
||||||
installed_modules = set(x['name'] for x in installed_module_names)
|
installed_modules = set(x['name'] for x in installed_module_names)
|
||||||
|
@ -71,7 +71,7 @@ class ir_model(osv.osv):
|
||||||
res = dict.fromkeys(ids)
|
res = dict.fromkeys(ids)
|
||||||
for model in models:
|
for model in models:
|
||||||
if self.pool.get(model.model):
|
if self.pool.get(model.model):
|
||||||
res[model.id] = self.pool.get(model.model).is_transient()
|
res[model.id] = self.pool[model.model].is_transient()
|
||||||
else:
|
else:
|
||||||
_logger.error('Missing model %s' % (model.model, ))
|
_logger.error('Missing model %s' % (model.model, ))
|
||||||
return res
|
return res
|
||||||
|
@ -91,7 +91,7 @@ class ir_model(osv.osv):
|
||||||
models = self.browse(cr, uid, ids)
|
models = self.browse(cr, uid, ids)
|
||||||
res = {}
|
res = {}
|
||||||
for model in models:
|
for model in models:
|
||||||
res[model.id] = self.pool.get("ir.ui.view").search(cr, uid, [('model', '=', model.model)])
|
res[model.id] = self.pool["ir.ui.view"].search(cr, uid, [('model', '=', model.model)])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
|
@ -144,7 +144,7 @@ class ir_model(osv.osv):
|
||||||
|
|
||||||
def _drop_table(self, cr, uid, ids, context=None):
|
def _drop_table(self, cr, uid, ids, context=None):
|
||||||
for model in self.browse(cr, uid, ids, context):
|
for model in self.browse(cr, uid, ids, context):
|
||||||
model_pool = self.pool.get(model.model)
|
model_pool = self.pool[model.model]
|
||||||
cr.execute('select relkind from pg_class where relname=%s', (model_pool._table,))
|
cr.execute('select relkind from pg_class where relname=%s', (model_pool._table,))
|
||||||
result = cr.fetchone()
|
result = cr.fetchone()
|
||||||
if result and result[0] == 'v':
|
if result and result[0] == 'v':
|
||||||
|
@ -168,7 +168,7 @@ class ir_model(osv.osv):
|
||||||
if not context.get(MODULE_UNINSTALL_FLAG):
|
if not context.get(MODULE_UNINSTALL_FLAG):
|
||||||
# only reload pool for normal unlink. For module uninstall the
|
# only reload pool for normal unlink. For module uninstall the
|
||||||
# reload is done independently in openerp.modules.loading
|
# reload is done independently in openerp.modules.loading
|
||||||
pooler.restart_pool(cr.dbname)
|
openerp.new_registry(cr.dbname)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -193,8 +193,8 @@ class ir_model(osv.osv):
|
||||||
field_name=vals['name'],
|
field_name=vals['name'],
|
||||||
field_state='manual',
|
field_state='manual',
|
||||||
select=vals.get('select_level', '0'))
|
select=vals.get('select_level', '0'))
|
||||||
self.pool.get(vals['model'])._auto_init(cr, ctx)
|
self.pool[vals['model']]._auto_init(cr, ctx)
|
||||||
#pooler.restart_pool(cr.dbname)
|
# openerp.new_registry(cr.dbname)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def instanciate(self, cr, user, model, context=None):
|
def instanciate(self, cr, user, model, context=None):
|
||||||
|
@ -298,7 +298,7 @@ class ir_model_fields(osv.osv):
|
||||||
|
|
||||||
def _drop_column(self, cr, uid, ids, context=None):
|
def _drop_column(self, cr, uid, ids, context=None):
|
||||||
for field in self.browse(cr, uid, ids, context):
|
for field in self.browse(cr, uid, ids, context):
|
||||||
model = self.pool.get(field.model)
|
model = self.pool[field.model]
|
||||||
cr.execute('select relkind from pg_class where relname=%s', (model._table,))
|
cr.execute('select relkind from pg_class where relname=%s', (model._table,))
|
||||||
result = cr.fetchone()
|
result = cr.fetchone()
|
||||||
cr.execute("SELECT column_name FROM information_schema.columns WHERE table_name ='%s' and column_name='%s'" %(model._table, field.name))
|
cr.execute("SELECT column_name FROM information_schema.columns WHERE table_name ='%s' and column_name='%s'" %(model._table, field.name))
|
||||||
|
@ -323,7 +323,7 @@ class ir_model_fields(osv.osv):
|
||||||
|
|
||||||
def create(self, cr, user, vals, context=None):
|
def create(self, cr, user, vals, context=None):
|
||||||
if 'model_id' in vals:
|
if 'model_id' in vals:
|
||||||
model_data = self.pool.get('ir.model').browse(cr, user, vals['model_id'])
|
model_data = self.pool['ir.model'].browse(cr, user, vals['model_id'])
|
||||||
vals['model'] = model_data.model
|
vals['model'] = model_data.model
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
|
@ -338,18 +338,18 @@ class ir_model_fields(osv.osv):
|
||||||
if not vals['name'].startswith('x_'):
|
if not vals['name'].startswith('x_'):
|
||||||
raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !"))
|
raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !"))
|
||||||
|
|
||||||
if vals.get('relation',False) and not self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])]):
|
if vals.get('relation',False) and not self.pool['ir.model'].search(cr, user, [('model','=',vals['relation'])]):
|
||||||
raise except_orm(_('Error'), _("Model %s does not exist!") % vals['relation'])
|
raise except_orm(_('Error'), _("Model %s does not exist!") % vals['relation'])
|
||||||
|
|
||||||
if self.pool.get(vals['model']):
|
if self.pool.get(vals['model']):
|
||||||
self.pool.get(vals['model']).__init__(self.pool, cr)
|
self.pool[vals['model']].__init__(self.pool, cr)
|
||||||
#Added context to _auto_init for special treatment to custom field for select_level
|
#Added context to _auto_init for special treatment to custom field for select_level
|
||||||
ctx = dict(context,
|
ctx = dict(context,
|
||||||
field_name=vals['name'],
|
field_name=vals['name'],
|
||||||
field_state='manual',
|
field_state='manual',
|
||||||
select=vals.get('select_level', '0'),
|
select=vals.get('select_level', '0'),
|
||||||
update_custom_fields=True)
|
update_custom_fields=True)
|
||||||
self.pool.get(vals['model'])._auto_init(cr, ctx)
|
self.pool[vals['model']]._auto_init(cr, ctx)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ class ir_model_constraint(Model):
|
||||||
Delete PostgreSQL foreign keys and constraints tracked by this model.
|
Delete PostgreSQL foreign keys and constraints tracked by this model.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if uid != SUPERUSER_ID and not self.pool.get('ir.model.access').check_groups(cr, uid, "base.group_system"):
|
if uid != SUPERUSER_ID and not self.pool['ir.model.access'].check_groups(cr, uid, "base.group_system"):
|
||||||
raise except_orm(_('Permission Denied'), (_('Administrator access is required to uninstall a module')))
|
raise except_orm(_('Permission Denied'), (_('Administrator access is required to uninstall a module')))
|
||||||
|
|
||||||
context = dict(context or {})
|
context = dict(context or {})
|
||||||
|
@ -559,7 +559,7 @@ class ir_model_relation(Model):
|
||||||
Delete PostgreSQL many2many relations tracked by this model.
|
Delete PostgreSQL many2many relations tracked by this model.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if uid != SUPERUSER_ID and not self.pool.get('ir.model.access').check_groups(cr, uid, "base.group_system"):
|
if uid != SUPERUSER_ID and not self.pool['ir.model.access'].check_groups(cr, uid, "base.group_system"):
|
||||||
raise except_orm(_('Permission Denied'), (_('Administrator access is required to uninstall a module')))
|
raise except_orm(_('Permission Denied'), (_('Administrator access is required to uninstall a module')))
|
||||||
|
|
||||||
ids_set = set(ids)
|
ids_set = set(ids)
|
||||||
|
@ -685,7 +685,7 @@ class ir_model_access(osv.osv):
|
||||||
# TransientModel records have no access rights, only an implicit access rule
|
# TransientModel records have no access rights, only an implicit access rule
|
||||||
if not self.pool.get(model_name):
|
if not self.pool.get(model_name):
|
||||||
_logger.error('Missing model %s' % (model_name, ))
|
_logger.error('Missing model %s' % (model_name, ))
|
||||||
elif self.pool.get(model_name).is_transient():
|
elif self.pool[model_name].is_transient():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# We check if a specific rule exists
|
# We check if a specific rule exists
|
||||||
|
@ -793,7 +793,7 @@ class ir_model_data(osv.osv):
|
||||||
|
|
||||||
for model in result:
|
for model in result:
|
||||||
try:
|
try:
|
||||||
r = dict(self.pool.get(model).name_get(cr, uid, result[model].keys(), context=context))
|
r = dict(self.pool[model].name_get(cr, uid, result[model].keys(), context=context))
|
||||||
for key,val in result[model].items():
|
for key,val in result[model].items():
|
||||||
result2[val] = r.get(key, False)
|
result2[val] = r.get(key, False)
|
||||||
except:
|
except:
|
||||||
|
@ -867,7 +867,7 @@ class ir_model_data(osv.osv):
|
||||||
def get_object(self, cr, uid, module, xml_id, context=None):
|
def get_object(self, cr, uid, module, xml_id, context=None):
|
||||||
"""Returns a browsable record for the given module name and xml_id or raise ValueError if not found"""
|
"""Returns a browsable record for the given module name and xml_id or raise ValueError if not found"""
|
||||||
res_model, res_id = self.get_object_reference(cr, uid, module, xml_id)
|
res_model, res_id = self.get_object_reference(cr, uid, module, xml_id)
|
||||||
result = self.pool.get(res_model).browse(cr, uid, res_id, context=context)
|
result = self.pool[res_model].browse(cr, uid, res_id, context=context)
|
||||||
if not result.exists():
|
if not result.exists():
|
||||||
raise ValueError('No record found for unique ID %s.%s. It may have been deleted.' % (module, xml_id))
|
raise ValueError('No record found for unique ID %s.%s. It may have been deleted.' % (module, xml_id))
|
||||||
return result
|
return result
|
||||||
|
@ -1001,7 +1001,7 @@ class ir_model_data(osv.osv):
|
||||||
cr.execute('select * from ir_values where model=%s and key=%s and name=%s'+where,(model, key, name))
|
cr.execute('select * from ir_values where model=%s and key=%s and name=%s'+where,(model, key, name))
|
||||||
res = cr.fetchone()
|
res = cr.fetchone()
|
||||||
if not res:
|
if not res:
|
||||||
ir_values_obj = pooler.get_pool(cr.dbname).get('ir.values')
|
ir_values_obj = openerp.registry(cr.dbname)['ir.values']
|
||||||
ir_values_obj.set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
|
ir_values_obj.set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
|
||||||
elif xml_id:
|
elif xml_id:
|
||||||
cr.execute('UPDATE ir_values set value=%s WHERE model=%s and key=%s and name=%s'+where,(value, model, key, name))
|
cr.execute('UPDATE ir_values set value=%s WHERE model=%s and key=%s and name=%s'+where,(value, model, key, name))
|
||||||
|
@ -1020,7 +1020,7 @@ class ir_model_data(osv.osv):
|
||||||
|
|
||||||
ids = self.search(cr, uid, [('module', 'in', modules_to_remove)])
|
ids = self.search(cr, uid, [('module', 'in', modules_to_remove)])
|
||||||
|
|
||||||
if uid != 1 and not self.pool.get('ir.model.access').check_groups(cr, uid, "base.group_system"):
|
if uid != 1 and not self.pool['ir.model.access'].check_groups(cr, uid, "base.group_system"):
|
||||||
raise except_orm(_('Permission Denied'), (_('Administrator access is required to uninstall a module')))
|
raise except_orm(_('Permission Denied'), (_('Administrator access is required to uninstall a module')))
|
||||||
|
|
||||||
context = dict(context or {})
|
context = dict(context or {})
|
||||||
|
@ -1063,7 +1063,7 @@ class ir_model_data(osv.osv):
|
||||||
if model == 'ir.model.fields':
|
if model == 'ir.model.fields':
|
||||||
# Don't remove the LOG_ACCESS_COLUMNS unless _log_access
|
# Don't remove the LOG_ACCESS_COLUMNS unless _log_access
|
||||||
# has been turned off on the model.
|
# has been turned off on the model.
|
||||||
field = self.pool.get(model).browse(cr, uid, [res_id], context=context)[0]
|
field = self.pool[model].browse(cr, uid, [res_id], context=context)[0]
|
||||||
if field.name in openerp.osv.orm.LOG_ACCESS_COLUMNS and self.pool[field.model]._log_access:
|
if field.name in openerp.osv.orm.LOG_ACCESS_COLUMNS and self.pool[field.model]._log_access:
|
||||||
continue
|
continue
|
||||||
if field.name == 'id':
|
if field.name == 'id':
|
||||||
|
@ -1071,7 +1071,7 @@ class ir_model_data(osv.osv):
|
||||||
_logger.info('Deleting %s@%s', res_id, model)
|
_logger.info('Deleting %s@%s', res_id, model)
|
||||||
try:
|
try:
|
||||||
cr.execute('SAVEPOINT record_unlink_save')
|
cr.execute('SAVEPOINT record_unlink_save')
|
||||||
self.pool.get(model).unlink(cr, uid, [res_id], context=context)
|
self.pool[model].unlink(cr, uid, [res_id], context=context)
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.info('Unable to delete %s@%s', res_id, model, exc_info=True)
|
_logger.info('Unable to delete %s@%s', res_id, model, exc_info=True)
|
||||||
cr.execute('ROLLBACK TO SAVEPOINT record_unlink_save')
|
cr.execute('ROLLBACK TO SAVEPOINT record_unlink_save')
|
||||||
|
@ -1084,8 +1084,8 @@ class ir_model_data(osv.osv):
|
||||||
unlink_if_refcount((model, res_id) for model, res_id in to_unlink
|
unlink_if_refcount((model, res_id) for model, res_id in to_unlink
|
||||||
if model == 'ir.model.fields')
|
if model == 'ir.model.fields')
|
||||||
|
|
||||||
ir_model_relation = self.pool.get('ir.model.relation')
|
ir_model_relation = self.pool['ir.model.relation']
|
||||||
ir_module_module = self.pool.get('ir.module.module')
|
ir_module_module = self.pool['ir.module.module']
|
||||||
modules_to_remove_ids = ir_module_module.search(cr, uid, [('name', 'in', modules_to_remove)])
|
modules_to_remove_ids = ir_module_module.search(cr, uid, [('name', 'in', modules_to_remove)])
|
||||||
relation_ids = ir_model_relation.search(cr, uid, [('module', 'in', modules_to_remove_ids)])
|
relation_ids = ir_model_relation.search(cr, uid, [('module', 'in', modules_to_remove_ids)])
|
||||||
ir_model_relation._module_data_uninstall(cr, uid, relation_ids, context)
|
ir_model_relation._module_data_uninstall(cr, uid, relation_ids, context)
|
||||||
|
@ -1118,6 +1118,6 @@ class ir_model_data(osv.osv):
|
||||||
for (model, res_id) in to_unlink:
|
for (model, res_id) in to_unlink:
|
||||||
if self.pool.get(model):
|
if self.pool.get(model):
|
||||||
_logger.info('Deleting %s@%s', res_id, model)
|
_logger.info('Deleting %s@%s', res_id, model)
|
||||||
self.pool.get(model).unlink(cr, uid, [res_id])
|
self.pool[model].unlink(cr, uid, [res_id])
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -39,7 +39,7 @@ except ImportError:
|
||||||
from StringIO import StringIO # NOQA
|
from StringIO import StringIO # NOQA
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
from openerp import modules, pooler, tools, addons
|
from openerp import modules, tools, addons
|
||||||
from openerp.modules.db import create_categories
|
from openerp.modules.db import create_categories
|
||||||
from openerp.tools.parse_version import parse_version
|
from openerp.tools.parse_version import parse_version
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
@ -473,14 +473,14 @@ class module(osv.osv):
|
||||||
function(cr, uid, ids, context=context)
|
function(cr, uid, ids, context=context)
|
||||||
|
|
||||||
cr.commit()
|
cr.commit()
|
||||||
_, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
|
||||||
|
|
||||||
config = pool.get('res.config').next(cr, uid, [], context=context) or {}
|
config = registry['res.config'].next(cr, uid, [], context=context) or {}
|
||||||
if config.get('type') not in ('ir.actions.act_window_close',):
|
if config.get('type') not in ('ir.actions.act_window_close',):
|
||||||
return config
|
return config
|
||||||
|
|
||||||
# reload the client; open the first available root menu
|
# reload the client; open the first available root menu
|
||||||
menu_obj = self.pool.get('ir.ui.menu')
|
menu_obj = registry['ir.ui.menu']
|
||||||
menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
|
menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
|
||||||
return {
|
return {
|
||||||
'type': 'ir.actions.client',
|
'type': 'ir.actions.client',
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from openerp import pooler
|
import openerp
|
||||||
from openerp.osv import osv, fields
|
from openerp.osv import osv, fields
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class base_module_upgrade(osv.osv_memory):
|
||||||
ir_module.download(cr, uid, ids, context=context)
|
ir_module.download(cr, uid, ids, context=context)
|
||||||
cr.commit() # save before re-creating cursor below
|
cr.commit() # save before re-creating cursor below
|
||||||
|
|
||||||
pooler.restart_pool(cr.dbname, update_module=True)
|
openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
|
||||||
|
|
||||||
ir_model_data = self.pool.get('ir.model.data')
|
ir_model_data = self.pool.get('ir.model.data')
|
||||||
__, res_id = ir_model_data.get_object_reference(cr, uid, 'base', 'view_base_module_upgrade_install')
|
__, res_id = ir_model_data.get_object_reference(cr, uid, 'base', 'view_base_module_upgrade_install')
|
||||||
|
|
|
@ -23,7 +23,7 @@ from operator import attrgetter
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
from openerp import pooler, SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
from openerp.osv import osv, fields
|
from openerp.osv import osv, fields
|
||||||
from openerp.tools import ustr
|
from openerp.tools import ustr
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
@ -72,7 +72,7 @@ class res_config_configurable(osv.osv_memory):
|
||||||
res['nodestroy'] = False
|
res['nodestroy'] = False
|
||||||
return res
|
return res
|
||||||
# reload the client; open the first available root menu
|
# reload the client; open the first available root menu
|
||||||
menu_obj = self.pool.get('ir.ui.menu')
|
menu_obj = self.pool['ir.ui.menu']
|
||||||
menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
|
menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
|
||||||
return {
|
return {
|
||||||
'type': 'ir.actions.client',
|
'type': 'ir.actions.client',
|
||||||
|
@ -271,7 +271,7 @@ class res_config_installer(osv.osv_memory):
|
||||||
:returns: a list of all installed modules in this installer
|
:returns: a list of all installed modules in this installer
|
||||||
:rtype: [browse_record]
|
:rtype: [browse_record]
|
||||||
"""
|
"""
|
||||||
modules = self.pool.get('ir.module.module')
|
modules = self.pool['ir.module.module']
|
||||||
|
|
||||||
selectable = [field for field in self._columns
|
selectable = [field for field in self._columns
|
||||||
if type(self._columns[field]) is fields.boolean]
|
if type(self._columns[field]) is fields.boolean]
|
||||||
|
@ -353,7 +353,7 @@ class res_config_installer(osv.osv_memory):
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def execute(self, cr, uid, ids, context=None):
|
def execute(self, cr, uid, ids, context=None):
|
||||||
modules = self.pool.get('ir.module.module')
|
modules = self.pool['ir.module.module']
|
||||||
to_install = list(self.modules_to_install(
|
to_install = list(self.modules_to_install(
|
||||||
cr, uid, ids, context=context))
|
cr, uid, ids, context=context))
|
||||||
_logger.info('Selecting addons %s to install', to_install)
|
_logger.info('Selecting addons %s to install', to_install)
|
||||||
|
@ -363,7 +363,7 @@ class res_config_installer(osv.osv_memory):
|
||||||
'to install', ['uninstalled'], context=context)
|
'to install', ['uninstalled'], context=context)
|
||||||
cr.commit()
|
cr.commit()
|
||||||
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
|
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
|
||||||
new_db, self.pool = pooler.restart_pool(cr.dbname, update_module=True)
|
openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
|
||||||
|
|
||||||
res_config_installer()
|
res_config_installer()
|
||||||
|
|
||||||
|
@ -455,8 +455,8 @@ class res_config_settings(osv.osv_memory):
|
||||||
'other': ['other_field', ...],
|
'other': ['other_field', ...],
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
ir_model_data = self.pool.get('ir.model.data')
|
ir_model_data = self.pool['ir.model.data']
|
||||||
ir_module = self.pool.get('ir.module.module')
|
ir_module = self.pool['ir.module.module']
|
||||||
def ref(xml_id):
|
def ref(xml_id):
|
||||||
mod, xml = xml_id.split('.', 1)
|
mod, xml = xml_id.split('.', 1)
|
||||||
return ir_model_data.get_object(cr, uid, mod, xml, context)
|
return ir_model_data.get_object(cr, uid, mod, xml, context)
|
||||||
|
@ -478,7 +478,7 @@ class res_config_settings(osv.osv_memory):
|
||||||
return {'default': defaults, 'group': groups, 'module': modules, 'other': others}
|
return {'default': defaults, 'group': groups, 'module': modules, 'other': others}
|
||||||
|
|
||||||
def default_get(self, cr, uid, fields, context=None):
|
def default_get(self, cr, uid, fields, context=None):
|
||||||
ir_values = self.pool.get('ir.values')
|
ir_values = self.pool['ir.values']
|
||||||
classified = self._get_classified_fields(cr, uid, context)
|
classified = self._get_classified_fields(cr, uid, context)
|
||||||
|
|
||||||
res = super(res_config_settings, self).default_get(cr, uid, fields, context)
|
res = super(res_config_settings, self).default_get(cr, uid, fields, context)
|
||||||
|
@ -505,8 +505,8 @@ class res_config_settings(osv.osv_memory):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def execute(self, cr, uid, ids, context=None):
|
def execute(self, cr, uid, ids, context=None):
|
||||||
ir_values = self.pool.get('ir.values')
|
ir_values = self.pool['ir.values']
|
||||||
ir_module = self.pool.get('ir.module.module')
|
ir_module = self.pool['ir.module.module']
|
||||||
classified = self._get_classified_fields(cr, uid, context)
|
classified = self._get_classified_fields(cr, uid, context)
|
||||||
|
|
||||||
config = self.browse(cr, uid, ids[0], context)
|
config = self.browse(cr, uid, ids[0], context)
|
||||||
|
@ -572,7 +572,7 @@ class res_config_settings(osv.osv_memory):
|
||||||
|
|
||||||
def cancel(self, cr, uid, ids, context=None):
|
def cancel(self, cr, uid, ids, context=None):
|
||||||
# ignore the current record, and send the action to reopen the view
|
# ignore the current record, and send the action to reopen the view
|
||||||
act_window = self.pool.get('ir.actions.act_window')
|
act_window = self.pool['ir.actions.act_window']
|
||||||
action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)])
|
action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)])
|
||||||
if action_ids:
|
if action_ids:
|
||||||
return act_window.read(cr, uid, action_ids[0], [], context=context)
|
return act_window.read(cr, uid, action_ids[0], [], context=context)
|
||||||
|
@ -588,7 +588,7 @@ class res_config_settings(osv.osv_memory):
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
ids = [ids]
|
ids = [ids]
|
||||||
|
|
||||||
act_window = self.pool.get('ir.actions.act_window')
|
act_window = self.pool['ir.actions.act_window']
|
||||||
action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)], context=context)
|
action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)], context=context)
|
||||||
name = self._name
|
name = self._name
|
||||||
if action_ids:
|
if action_ids:
|
||||||
|
@ -606,8 +606,8 @@ class res_config_settings(osv.osv_memory):
|
||||||
- t[1]: long: id of the menuitem's action
|
- t[1]: long: id of the menuitem's action
|
||||||
"""
|
"""
|
||||||
module_name, menu_xml_id = menu_xml_id.split('.')
|
module_name, menu_xml_id = menu_xml_id.split('.')
|
||||||
dummy, menu_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, module_name, menu_xml_id)
|
dummy, menu_id = self.pool['ir.model.data'].get_object_reference(cr, uid, module_name, menu_xml_id)
|
||||||
ir_ui_menu = self.pool.get('ir.ui.menu').browse(cr, uid, menu_id, context=context)
|
ir_ui_menu = self.pool['ir.ui.menu'].browse(cr, uid, menu_id, context=context)
|
||||||
|
|
||||||
return (ir_ui_menu.complete_name, ir_ui_menu.action.id)
|
return (ir_ui_menu.complete_name, ir_ui_menu.action.id)
|
||||||
|
|
||||||
|
@ -621,7 +621,7 @@ class res_config_settings(osv.osv_memory):
|
||||||
"""
|
"""
|
||||||
model_name, field_name = full_field_name.rsplit('.', 1)
|
model_name, field_name = full_field_name.rsplit('.', 1)
|
||||||
|
|
||||||
return self.pool.get(model_name).fields_get(cr, uid, allfields=[field_name], context=context)[field_name]['string']
|
return self.pool[model_name].fields_get(cr, uid, allfields=[field_name], context=context)[field_name]['string']
|
||||||
|
|
||||||
def get_config_warning(self, cr, msg, context=None):
|
def get_config_warning(self, cr, msg, context=None):
|
||||||
"""
|
"""
|
||||||
|
@ -652,7 +652,7 @@ class res_config_settings(osv.osv_memory):
|
||||||
Cannot find any account journal of %s type for this company.\n\nYou can create one in the %%(menu:account.menu_account_config)s.
|
Cannot find any account journal of %s type for this company.\n\nYou can create one in the %%(menu:account.menu_account_config)s.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
res_config_obj = pooler.get_pool(cr.dbname).get('res.config.settings')
|
res_config_obj = openerp.registry(cr.dbname)['res.config.settings']
|
||||||
regex_path = r'%\(((?:menu|field):[a-z_\.]*)\)s'
|
regex_path = r'%\(((?:menu|field):[a-z_\.]*)\)s'
|
||||||
|
|
||||||
# Process the message
|
# Process the message
|
||||||
|
|
|
@ -27,13 +27,13 @@ import re
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
from openerp import pooler, tools
|
from openerp import tools
|
||||||
from openerp.osv import osv, fields
|
from openerp.osv import osv, fields
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
class format_address(object):
|
class format_address(object):
|
||||||
def fields_view_get_address(self, cr, uid, arch, context={}):
|
def fields_view_get_address(self, cr, uid, arch, context={}):
|
||||||
user_obj = self.pool.get('res.users')
|
user_obj = self.pool['res.users']
|
||||||
fmt = user_obj.browse(cr, SUPERUSER_ID, uid, context).company_id.country_id
|
fmt = user_obj.browse(cr, SUPERUSER_ID, uid, context).company_id.country_id
|
||||||
fmt = fmt and fmt.address_format
|
fmt = fmt and fmt.address_format
|
||||||
layouts = {
|
layouts = {
|
||||||
|
@ -154,7 +154,7 @@ class res_partner_title(osv.osv):
|
||||||
}
|
}
|
||||||
|
|
||||||
def _lang_get(self, cr, uid, context=None):
|
def _lang_get(self, cr, uid, context=None):
|
||||||
lang_pool = self.pool.get('res.lang')
|
lang_pool = self.pool['res.lang']
|
||||||
ids = lang_pool.search(cr, uid, [], context=context)
|
ids = lang_pool.search(cr, uid, [], context=context)
|
||||||
res = lang_pool.read(cr, uid, ids, ['code', 'name'], context)
|
res = lang_pool.read(cr, uid, ids, ['code', 'name'], context)
|
||||||
return [(r['code'], r['name']) for r in res]
|
return [(r['code'], r['name']) for r in res]
|
||||||
|
@ -287,7 +287,7 @@ class res_partner(osv.osv, format_address):
|
||||||
|
|
||||||
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||||
if (not view_id) and (view_type=='form') and context and context.get('force_email', False):
|
if (not view_id) and (view_type=='form') and context and context.get('force_email', False):
|
||||||
view_id = self.pool.get('ir.model.data').get_object_reference(cr, user, 'base', 'view_partner_simple_form')[1]
|
view_id = self.pool['ir.model.data'].get_object_reference(cr, user, 'base', 'view_partner_simple_form')[1]
|
||||||
res = super(res_partner,self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
res = super(res_partner,self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||||
if view_type == 'form':
|
if view_type == 'form':
|
||||||
res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context)
|
res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context)
|
||||||
|
@ -299,7 +299,7 @@ class res_partner(osv.osv, format_address):
|
||||||
'tz': lambda self, cr, uid, ctx: ctx.get('tz', False),
|
'tz': lambda self, cr, uid, ctx: ctx.get('tz', False),
|
||||||
'customer': True,
|
'customer': True,
|
||||||
'category_id': _default_category,
|
'category_id': _default_category,
|
||||||
'company_id': lambda self, cr, uid, ctx: self.pool.get('res.company')._company_default_get(cr, uid, 'res.partner', context=ctx),
|
'company_id': lambda self, cr, uid, ctx: self.pool['res.company']._company_default_get(cr, uid, 'res.partner', context=ctx),
|
||||||
'color': 0,
|
'color': 0,
|
||||||
'is_company': False,
|
'is_company': False,
|
||||||
'type': 'default',
|
'type': 'default',
|
||||||
|
@ -336,12 +336,12 @@ class res_partner(osv.osv, format_address):
|
||||||
|
|
||||||
def onchange_state(self, cr, uid, ids, state_id, context=None):
|
def onchange_state(self, cr, uid, ids, state_id, context=None):
|
||||||
if state_id:
|
if state_id:
|
||||||
country_id = self.pool.get('res.country.state').browse(cr, uid, state_id, context).country_id.id
|
country_id = self.pool['res.country.state'].browse(cr, uid, state_id, context).country_id.id
|
||||||
return {'value':{'country_id':country_id}}
|
return {'value':{'country_id':country_id}}
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _check_ean_key(self, cr, uid, ids, context=None):
|
def _check_ean_key(self, cr, uid, ids, context=None):
|
||||||
for partner_o in pooler.get_pool(cr.dbname).get('res.partner').read(cr, uid, ids, ['ean13',]):
|
for partner_o in self.pool['res.partner'].read(cr, uid, ids, ['ean13',]):
|
||||||
thisean=partner_o['ean13']
|
thisean=partner_o['ean13']
|
||||||
if thisean and thisean!='':
|
if thisean and thisean!='':
|
||||||
if len(thisean)!=13:
|
if len(thisean)!=13:
|
||||||
|
@ -487,7 +487,7 @@ class res_partner(osv.osv, format_address):
|
||||||
|
|
||||||
def email_send(self, cr, uid, ids, email_from, subject, body, on_error=''):
|
def email_send(self, cr, uid, ids, email_from, subject, body, on_error=''):
|
||||||
while len(ids):
|
while len(ids):
|
||||||
self.pool.get('ir.cron').create(cr, uid, {
|
self.pool['ir.cron'].create(cr, uid, {
|
||||||
'name': 'Send Partner Emails',
|
'name': 'Send Partner Emails',
|
||||||
'user_id': uid,
|
'user_id': uid,
|
||||||
'model': 'res.partner',
|
'model': 'res.partner',
|
||||||
|
@ -523,12 +523,12 @@ class res_partner(osv.osv, format_address):
|
||||||
if res: return res
|
if res: return res
|
||||||
if not context.get('category_id', False):
|
if not context.get('category_id', False):
|
||||||
return False
|
return False
|
||||||
return _('Partners: ')+self.pool.get('res.partner.category').browse(cr, uid, context['category_id'], context).name
|
return _('Partners: ')+self.pool['res.partner.category'].browse(cr, uid, context['category_id'], context).name
|
||||||
|
|
||||||
def main_partner(self, cr, uid):
|
def main_partner(self, cr, uid):
|
||||||
''' Return the id of the main partner
|
''' Return the id of the main partner
|
||||||
'''
|
'''
|
||||||
model_data = self.pool.get('ir.model.data')
|
model_data = self.pool['ir.model.data']
|
||||||
return model_data.browse(cr, uid,
|
return model_data.browse(cr, uid,
|
||||||
model_data.search(cr, uid, [('module','=','base'),
|
model_data.search(cr, uid, [('module','=','base'),
|
||||||
('name','=','main_partner')])[0],
|
('name','=','main_partner')])[0],
|
||||||
|
|
|
@ -26,7 +26,7 @@ from lxml.builder import E
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
from openerp import pooler, tools
|
from openerp import tools
|
||||||
import openerp.exceptions
|
import openerp.exceptions
|
||||||
from openerp.osv import fields,osv
|
from openerp.osv import fields,osv
|
||||||
from openerp.osv.orm import browse_record
|
from openerp.osv.orm import browse_record
|
||||||
|
@ -98,7 +98,7 @@ class groups(osv.osv):
|
||||||
raise osv.except_osv(_('Error'),
|
raise osv.except_osv(_('Error'),
|
||||||
_('The name of the group can not start with "-"'))
|
_('The name of the group can not start with "-"'))
|
||||||
res = super(groups, self).write(cr, uid, ids, vals, context=context)
|
res = super(groups, self).write(cr, uid, ids, vals, context=context)
|
||||||
self.pool.get('ir.model.access').call_cache_clearing_methods(cr)
|
self.pool['ir.model.access'].call_cache_clearing_methods(cr)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
groups()
|
groups()
|
||||||
|
@ -178,7 +178,7 @@ class res_users(osv.osv):
|
||||||
partner.onchange_type method, but applied to the user object.
|
partner.onchange_type method, but applied to the user object.
|
||||||
"""
|
"""
|
||||||
partner_ids = [user.partner_id.id for user in self.browse(cr, uid, ids, context=context)]
|
partner_ids = [user.partner_id.id for user in self.browse(cr, uid, ids, context=context)]
|
||||||
return self.pool.get('res.partner').onchange_type(cr, uid, partner_ids, is_company, context=context)
|
return self.pool['res.partner'].onchange_type(cr, uid, partner_ids, is_company, context=context)
|
||||||
|
|
||||||
def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, context=None):
|
def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, context=None):
|
||||||
""" Wrapper on the user.partner onchange_address, because some calls to the
|
""" Wrapper on the user.partner onchange_address, because some calls to the
|
||||||
|
@ -186,7 +186,7 @@ class res_users(osv.osv):
|
||||||
partner.onchange_type method, but applied to the user object.
|
partner.onchange_type method, but applied to the user object.
|
||||||
"""
|
"""
|
||||||
partner_ids = [user.partner_id.id for user in self.browse(cr, uid, ids, context=context)]
|
partner_ids = [user.partner_id.id for user in self.browse(cr, uid, ids, context=context)]
|
||||||
return self.pool.get('res.partner').onchange_address(cr, uid, partner_ids, use_parent_address, parent_id, context=context)
|
return self.pool['res.partner'].onchange_address(cr, uid, partner_ids, use_parent_address, parent_id, context=context)
|
||||||
|
|
||||||
def _check_company(self, cr, uid, ids, context=None):
|
def _check_company(self, cr, uid, ids, context=None):
|
||||||
return all(((this.company_id in this.company_ids) or not this.company_ids) for this in self.browse(cr, uid, ids, context))
|
return all(((this.company_id in this.company_ids) or not this.company_ids) for this in self.browse(cr, uid, ids, context))
|
||||||
|
@ -202,7 +202,7 @@ class res_users(osv.osv):
|
||||||
def _get_company(self,cr, uid, context=None, uid2=False):
|
def _get_company(self,cr, uid, context=None, uid2=False):
|
||||||
if not uid2:
|
if not uid2:
|
||||||
uid2 = uid
|
uid2 = uid
|
||||||
user = self.pool.get('res.users').read(cr, uid, uid2, ['company_id'], context)
|
user = self.pool['res.users'].read(cr, uid, uid2, ['company_id'], context)
|
||||||
company_id = user.get('company_id', False)
|
company_id = user.get('company_id', False)
|
||||||
return company_id and company_id[0] or False
|
return company_id and company_id[0] or False
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ class res_users(osv.osv):
|
||||||
'company_id': _get_company,
|
'company_id': _get_company,
|
||||||
'company_ids': _get_companies,
|
'company_ids': _get_companies,
|
||||||
'groups_id': _get_group,
|
'groups_id': _get_group,
|
||||||
'image': lambda self, cr, uid, ctx={}: self.pool.get('res.partner')._get_default_image(cr, uid, False, ctx, colorize=True),
|
'image': lambda self, cr, uid, ctx={}: self.pool['res.partner']._get_default_image(cr, uid, False, ctx, colorize=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
# User can write on a few of his own fields (but not his groups for example)
|
# User can write on a few of his own fields (but not his groups for example)
|
||||||
|
@ -266,7 +266,7 @@ class res_users(osv.osv):
|
||||||
uid = SUPERUSER_ID
|
uid = SUPERUSER_ID
|
||||||
|
|
||||||
result = super(res_users, self).read(cr, uid, ids, fields=fields, context=context, load=load)
|
result = super(res_users, self).read(cr, uid, ids, fields=fields, context=context, load=load)
|
||||||
canwrite = self.pool.get('ir.model.access').check(cr, uid, 'res.users', 'write', False)
|
canwrite = self.pool['ir.model.access'].check(cr, uid, 'res.users', 'write', False)
|
||||||
if not canwrite:
|
if not canwrite:
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
result = override_password(result)
|
result = override_password(result)
|
||||||
|
@ -291,8 +291,8 @@ class res_users(osv.osv):
|
||||||
res = super(res_users, self).write(cr, uid, ids, values, context=context)
|
res = super(res_users, self).write(cr, uid, ids, values, context=context)
|
||||||
|
|
||||||
# clear caches linked to the users
|
# clear caches linked to the users
|
||||||
self.pool.get('ir.model.access').call_cache_clearing_methods(cr)
|
self.pool['ir.model.access'].call_cache_clearing_methods(cr)
|
||||||
clear = partial(self.pool.get('ir.rule').clear_cache, cr)
|
clear = partial(self.pool['ir.rule'].clear_cache, cr)
|
||||||
map(clear, ids)
|
map(clear, ids)
|
||||||
db = cr.dbname
|
db = cr.dbname
|
||||||
if db in self._uid_cache:
|
if db in self._uid_cache:
|
||||||
|
@ -352,7 +352,7 @@ class res_users(osv.osv):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def action_get(self, cr, uid, context=None):
|
def action_get(self, cr, uid, context=None):
|
||||||
dataobj = self.pool.get('ir.model.data')
|
dataobj = self.pool['ir.model.data']
|
||||||
data_id = dataobj._get_id(cr, SUPERUSER_ID, 'base', 'action_res_users_my')
|
data_id = dataobj._get_id(cr, SUPERUSER_ID, 'base', 'action_res_users_my')
|
||||||
return dataobj.browse(cr, uid, data_id, context=context).res_id
|
return dataobj.browse(cr, uid, data_id, context=context).res_id
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ class res_users(osv.osv):
|
||||||
if not password:
|
if not password:
|
||||||
return False
|
return False
|
||||||
user_id = False
|
user_id = False
|
||||||
cr = pooler.get_db(db).cursor()
|
cr = self.pool.db.cursor()
|
||||||
try:
|
try:
|
||||||
# autocommit: our single update request will be performed atomically.
|
# autocommit: our single update request will be performed atomically.
|
||||||
# (In this way, there is no opportunity to have two transactions
|
# (In this way, there is no opportunity to have two transactions
|
||||||
|
@ -423,10 +423,10 @@ class res_users(osv.osv):
|
||||||
# Successfully logged in as admin!
|
# Successfully logged in as admin!
|
||||||
# Attempt to guess the web base url...
|
# Attempt to guess the web base url...
|
||||||
if user_agent_env and user_agent_env.get('base_location'):
|
if user_agent_env and user_agent_env.get('base_location'):
|
||||||
cr = pooler.get_db(db).cursor()
|
cr = self.pool.db.cursor()
|
||||||
try:
|
try:
|
||||||
base = user_agent_env['base_location']
|
base = user_agent_env['base_location']
|
||||||
self.pool.get('ir.config_parameter').set_param(cr, uid, 'web.base.url', base)
|
self.pool['ir.config_parameter'].set_param(cr, uid, 'web.base.url', base)
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.exception("Failed to update web.base.url configuration parameter")
|
_logger.exception("Failed to update web.base.url configuration parameter")
|
||||||
|
@ -442,7 +442,7 @@ class res_users(osv.osv):
|
||||||
raise openerp.exceptions.AccessDenied()
|
raise openerp.exceptions.AccessDenied()
|
||||||
if self._uid_cache.get(db, {}).get(uid) == passwd:
|
if self._uid_cache.get(db, {}).get(uid) == passwd:
|
||||||
return
|
return
|
||||||
cr = pooler.get_db(db).cursor()
|
cr = self.pool.db.cursor()
|
||||||
try:
|
try:
|
||||||
self.check_credentials(cr, uid, passwd)
|
self.check_credentials(cr, uid, passwd)
|
||||||
if self._uid_cache.has_key(db):
|
if self._uid_cache.has_key(db):
|
||||||
|
@ -690,7 +690,7 @@ class groups_view(osv.osv):
|
||||||
|
|
||||||
def get_user_groups_view(self, cr, uid, context=None):
|
def get_user_groups_view(self, cr, uid, context=None):
|
||||||
try:
|
try:
|
||||||
view = self.pool.get('ir.model.data').get_object(cr, SUPERUSER_ID, 'base', 'user_groups_view', context)
|
view = self.pool['ir.model.data'].get_object(cr, SUPERUSER_ID, 'base', 'user_groups_view', context)
|
||||||
assert view and view._table_name == 'ir.ui.view'
|
assert view and view._table_name == 'ir.ui.view'
|
||||||
except Exception:
|
except Exception:
|
||||||
view = False
|
view = False
|
||||||
|
@ -826,7 +826,7 @@ class users_view(osv.osv):
|
||||||
def fields_get(self, cr, uid, allfields=None, context=None, write_access=True):
|
def fields_get(self, cr, uid, allfields=None, context=None, write_access=True):
|
||||||
res = super(users_view, self).fields_get(cr, uid, allfields, context, write_access)
|
res = super(users_view, self).fields_get(cr, uid, allfields, context, write_access)
|
||||||
# add reified groups fields
|
# add reified groups fields
|
||||||
for app, kind, gs in self.pool.get('res.groups').get_groups_by_application(cr, uid, context):
|
for app, kind, gs in self.pool['res.groups'].get_groups_by_application(cr, uid, context):
|
||||||
if kind == 'selection':
|
if kind == 'selection':
|
||||||
# selection group field
|
# selection group field
|
||||||
tips = ['%s: %s' % (g.name, g.comment) for g in gs if g.comment]
|
tips = ['%s: %s' % (g.name, g.comment) for g in gs if g.comment]
|
||||||
|
|
|
@ -33,7 +33,6 @@ import openerp.osv as osv
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
import openerp.tools.osutil as osutil
|
import openerp.tools.osutil as osutil
|
||||||
from openerp.tools.safe_eval import safe_eval as eval
|
from openerp.tools.safe_eval import safe_eval as eval
|
||||||
import openerp.pooler as pooler
|
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
import openerp.netsvc as netsvc
|
import openerp.netsvc as netsvc
|
||||||
|
|
|
@ -33,7 +33,6 @@ import openerp.osv as osv
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
import openerp.tools.osutil as osutil
|
import openerp.tools.osutil as osutil
|
||||||
from openerp.tools.safe_eval import safe_eval as eval
|
from openerp.tools.safe_eval import safe_eval as eval
|
||||||
import openerp.pooler as pooler
|
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
import openerp.netsvc as netsvc
|
import openerp.netsvc as netsvc
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import openerp
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
from openerp.tools.safe_eval import safe_eval as eval
|
from openerp.tools.safe_eval import safe_eval as eval
|
||||||
import print_xml
|
import print_xml
|
||||||
|
@ -31,7 +32,6 @@ import common
|
||||||
from openerp.osv.osv import except_osv
|
from openerp.osv.osv import except_osv
|
||||||
from openerp.osv.orm import browse_null
|
from openerp.osv.orm import browse_null
|
||||||
from openerp.osv.orm import browse_record_list
|
from openerp.osv.orm import browse_record_list
|
||||||
import openerp.pooler as pooler
|
|
||||||
from pychart import *
|
from pychart import *
|
||||||
import misc
|
import misc
|
||||||
import cStringIO
|
import cStringIO
|
||||||
|
@ -127,22 +127,22 @@ class report_custom(report_int):
|
||||||
def create(self, cr, uid, ids, datas, context=None):
|
def create(self, cr, uid, ids, datas, context=None):
|
||||||
if not context:
|
if not context:
|
||||||
context={}
|
context={}
|
||||||
self.pool = pooler.get_pool(cr.dbname)
|
self.pool = openerp.registry(cr.dbname)
|
||||||
report = self.pool.get('ir.report.custom').browse(cr, uid, [datas['report_id']])[0]
|
report = self.pool['ir.report.custom'].browse(cr, uid, [datas['report_id']])[0]
|
||||||
datas['model'] = report.model_id.model
|
datas['model'] = report.model_id.model
|
||||||
if report.menu_id:
|
if report.menu_id:
|
||||||
ids = self.pool.get(report.model_id.model).search(cr, uid, [])
|
ids = self.pool[report.model_id.model].search(cr, uid, [])
|
||||||
datas['ids'] = ids
|
datas['ids'] = ids
|
||||||
|
|
||||||
report_id = datas['report_id']
|
report_id = datas['report_id']
|
||||||
report = self.pool.get('ir.report.custom').read(cr, uid, [report_id], context=context)[0]
|
report = self.pool['ir.report.custom'].read(cr, uid, [report_id], context=context)[0]
|
||||||
fields = self.pool.get('ir.report.custom.fields').read(cr, uid, report['fields_child0'], context=context)
|
fields = self.pool['ir.report.custom.fields'].read(cr, uid, report['fields_child0'], context=context)
|
||||||
|
|
||||||
fields.sort(lambda x,y : x['sequence'] - y['sequence'])
|
fields.sort(lambda x,y : x['sequence'] - y['sequence'])
|
||||||
|
|
||||||
if report['field_parent']:
|
if report['field_parent']:
|
||||||
parent_field = self.pool.get('ir.model.fields').read(cr, uid, [report['field_parent'][0]], ['model'])
|
parent_field = self.pool['ir.model.fields'].read(cr, uid, [report['field_parent'][0]], ['model'])
|
||||||
model_name = self.pool.get('ir.model').read(cr, uid, [report['model_id'][0]], ['model'], context=context)[0]['model']
|
model_name = self.pool['ir.model'].read(cr, uid, [report['model_id'][0]], ['model'], context=context)[0]['model']
|
||||||
|
|
||||||
fct = {
|
fct = {
|
||||||
'id': lambda x: x,
|
'id': lambda x: x,
|
||||||
|
@ -158,7 +158,7 @@ class report_custom(report_int):
|
||||||
field_child = f['field_child'+str(i)]
|
field_child = f['field_child'+str(i)]
|
||||||
if field_child:
|
if field_child:
|
||||||
row.append(
|
row.append(
|
||||||
self.pool.get('ir.model.fields').read(cr, uid, [field_child[0]], ['name'], context=context)[0]['name']
|
self.pool['ir.model.fields'].read(cr, uid, [field_child[0]], ['name'], context=context)[0]['name']
|
||||||
)
|
)
|
||||||
if f['fc'+str(i)+'_operande']:
|
if f['fc'+str(i)+'_operande']:
|
||||||
fct_name = 'id'
|
fct_name = 'id'
|
||||||
|
@ -171,7 +171,7 @@ class report_custom(report_int):
|
||||||
cond.append(None)
|
cond.append(None)
|
||||||
new_fields.append(row)
|
new_fields.append(row)
|
||||||
new_cond.append(cond)
|
new_cond.append(cond)
|
||||||
objs = self.pool.get(model_name).browse(cr, uid, ids)
|
objs = self.pool[model_name].browse(cr, uid, ids)
|
||||||
|
|
||||||
# Group by
|
# Group by
|
||||||
groupby = None
|
groupby = None
|
||||||
|
@ -340,7 +340,7 @@ class report_custom(report_int):
|
||||||
|
|
||||||
|
|
||||||
def _create_lines(self, cr, uid, ids, report, fields, results, context):
|
def _create_lines(self, cr, uid, ids, report, fields, results, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = openerp.registry(cr.dbname)
|
||||||
pdf_string = cStringIO.StringIO()
|
pdf_string = cStringIO.StringIO()
|
||||||
can = canvas.init(fname=pdf_string, format='pdf')
|
can = canvas.init(fname=pdf_string, format='pdf')
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ class report_custom(report_int):
|
||||||
for f in fields:
|
for f in fields:
|
||||||
field_id = (f['field_child3'] and f['field_child3'][0]) or (f['field_child2'] and f['field_child2'][0]) or (f['field_child1'] and f['field_child1'][0]) or (f['field_child0'] and f['field_child0'][0])
|
field_id = (f['field_child3'] and f['field_child3'][0]) or (f['field_child2'] and f['field_child2'][0]) or (f['field_child1'] and f['field_child1'][0]) or (f['field_child0'] and f['field_child0'][0])
|
||||||
if field_id:
|
if field_id:
|
||||||
type = pool.get('ir.model.fields').read(cr, uid, [field_id],['ttype'])
|
type = pool['ir.model.fields'].read(cr, uid, [field_id],['ttype'])
|
||||||
if type[0]['ttype'] == 'date':
|
if type[0]['ttype'] == 'date':
|
||||||
date_idx = idx
|
date_idx = idx
|
||||||
fct[idx] = process_date[report['frequency']]
|
fct[idx] = process_date[report['frequency']]
|
||||||
|
@ -444,7 +444,7 @@ class report_custom(report_int):
|
||||||
|
|
||||||
|
|
||||||
def _create_bars(self, cr, uid, ids, report, fields, results, context):
|
def _create_bars(self, cr, uid, ids, report, fields, results, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = openerp.registry(cr.dbname)
|
||||||
pdf_string = cStringIO.StringIO()
|
pdf_string = cStringIO.StringIO()
|
||||||
can = canvas.init(fname=pdf_string, format='pdf')
|
can = canvas.init(fname=pdf_string, format='pdf')
|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ class report_custom(report_int):
|
||||||
for f in fields:
|
for f in fields:
|
||||||
field_id = (f['field_child3'] and f['field_child3'][0]) or (f['field_child2'] and f['field_child2'][0]) or (f['field_child1'] and f['field_child1'][0]) or (f['field_child0'] and f['field_child0'][0])
|
field_id = (f['field_child3'] and f['field_child3'][0]) or (f['field_child2'] and f['field_child2'][0]) or (f['field_child1'] and f['field_child1'][0]) or (f['field_child0'] and f['field_child0'][0])
|
||||||
if field_id:
|
if field_id:
|
||||||
type = pool.get('ir.model.fields').read(cr, uid, [field_id],['ttype'])
|
type = pool['ir.model.fields'].read(cr, uid, [field_id],['ttype'])
|
||||||
if type[0]['ttype'] == 'date':
|
if type[0]['ttype'] == 'date':
|
||||||
date_idx = idx
|
date_idx = idx
|
||||||
fct[idx] = process_date[report['frequency']]
|
fct[idx] = process_date[report['frequency']]
|
||||||
|
|
|
@ -23,7 +23,8 @@ import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import openerp.pooler as pooler
|
|
||||||
|
import openerp
|
||||||
|
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
import openerp.modules
|
import openerp.modules
|
||||||
|
@ -90,8 +91,8 @@ class report_rml(report_int):
|
||||||
if report_type == 'raw':
|
if report_type == 'raw':
|
||||||
return xml, report_type
|
return xml, report_type
|
||||||
rml = self.create_rml(cr, xml, uid, context)
|
rml = self.create_rml(cr, xml, uid, context)
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
ir_actions_report_xml_obj = pool.get('ir.actions.report.xml')
|
ir_actions_report_xml_obj = registry['ir.actions.report.xml']
|
||||||
report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context)
|
report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context)
|
||||||
self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report'
|
self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report'
|
||||||
create_doc = self.generators[report_type]
|
create_doc = self.generators[report_type]
|
||||||
|
@ -140,8 +141,8 @@ class report_rml(report_int):
|
||||||
self.internal_header=True
|
self.internal_header=True
|
||||||
if not context:
|
if not context:
|
||||||
context={}
|
context={}
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
ir_translation_obj = pool.get('ir.translation')
|
ir_translation_obj = registry['ir.translation']
|
||||||
|
|
||||||
# In some case we might not use xsl ...
|
# In some case we might not use xsl ...
|
||||||
if not self.xsl:
|
if not self.xsl:
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
import openerp
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
from openerp.tools.safe_eval import safe_eval
|
from openerp.tools.safe_eval import safe_eval
|
||||||
import print_fnc
|
import print_fnc
|
||||||
from openerp.osv.orm import browse_null, browse_record
|
from openerp.osv.orm import browse_null, browse_record
|
||||||
import openerp.pooler as pooler
|
|
||||||
|
|
||||||
class InheritDict(dict):
|
class InheritDict(dict):
|
||||||
# Might be usefull when we're doing name lookup for call or eval.
|
# Might be usefull when we're doing name lookup for call or eval.
|
||||||
|
@ -54,7 +54,7 @@ class document(object):
|
||||||
def __init__(self, cr, uid, datas, func=False):
|
def __init__(self, cr, uid, datas, func=False):
|
||||||
# create a new document
|
# create a new document
|
||||||
self.cr = cr
|
self.cr = cr
|
||||||
self.pool = pooler.get_pool(cr.dbname)
|
self.pool = openerp.registry(cr.dbname)
|
||||||
self.func = func or {}
|
self.func = func or {}
|
||||||
self.datas = datas
|
self.datas = datas
|
||||||
self.uid = uid
|
self.uid = uid
|
||||||
|
@ -134,8 +134,8 @@ class document(object):
|
||||||
|
|
||||||
value = self.get_value(browser, attrs['name'])
|
value = self.get_value(browser, attrs['name'])
|
||||||
|
|
||||||
ids = self.pool.get('ir.attachment').search(self.cr, self.uid, [('res_model','=',model),('res_id','=',int(value))])
|
ids = self.pool['ir.attachment'].search(self.cr, self.uid, [('res_model','=',model),('res_id','=',int(value))])
|
||||||
datas = self.pool.get('ir.attachment').read(self.cr, self.uid, ids)
|
datas = self.pool['ir.attachment'].read(self.cr, self.uid, ids)
|
||||||
|
|
||||||
if len(datas):
|
if len(datas):
|
||||||
# if there are several, pick first
|
# if there are several, pick first
|
||||||
|
@ -264,7 +264,7 @@ class document(object):
|
||||||
def parse_tree(self, ids, model, context=None):
|
def parse_tree(self, ids, model, context=None):
|
||||||
if not context:
|
if not context:
|
||||||
context={}
|
context={}
|
||||||
browser = self.pool.get(model).browse(self.cr, self.uid, ids, context)
|
browser = self.pool[model].browse(self.cr, self.uid, ids, context)
|
||||||
self.parse_node(self.dom, self.doc, browser)
|
self.parse_node(self.dom, self.doc, browser)
|
||||||
|
|
||||||
def parse_string(self, xml, ids, model, context=None):
|
def parse_string(self, xml, ids, model, context=None):
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
import openerp
|
||||||
from openerp.report.interface import report_int
|
from openerp.report.interface import report_int
|
||||||
import openerp.pooler as pooler
|
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
|
|
||||||
from openerp.report import render
|
from openerp.report import render
|
||||||
|
@ -55,8 +55,8 @@ class report_printscreen_list(report_int):
|
||||||
if not context:
|
if not context:
|
||||||
context={}
|
context={}
|
||||||
datas['ids'] = ids
|
datas['ids'] = ids
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
model = pool.get(datas['model'])
|
model = registry[datas['model']]
|
||||||
# title come from description of model which are specified in py file.
|
# title come from description of model which are specified in py file.
|
||||||
self.title = model._description
|
self.title = model._description
|
||||||
result = model.fields_view_get(cr, uid, view_type='form', context=context)
|
result = model.fields_view_get(cr, uid, view_type='form', context=context)
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
import openerp
|
||||||
from openerp.report.interface import report_int
|
from openerp.report.interface import report_int
|
||||||
import openerp.pooler as pooler
|
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
from openerp.tools.safe_eval import safe_eval as eval
|
from openerp.tools.safe_eval import safe_eval as eval
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
@ -66,12 +66,12 @@ class report_printscreen_list(report_int):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.groupby = context.get('group_by',[])
|
self.groupby = context.get('group_by',[])
|
||||||
self.groupby_no_leaf = context.get('group_by_no_leaf',False)
|
self.groupby_no_leaf = context.get('group_by_no_leaf',False)
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
model = pool.get(datas['model'])
|
model = registry[datas['model']]
|
||||||
model_id = pool.get('ir.model').search(cr, uid, [('model','=',model._name)])
|
model_id = registry['ir.model'].search(cr, uid, [('model','=',model._name)])
|
||||||
model_desc = model._description
|
model_desc = model._description
|
||||||
if model_id:
|
if model_id:
|
||||||
model_desc = pool.get('ir.model').browse(cr, uid, model_id[0], context).name
|
model_desc = registry['ir.model'].browse(cr, uid, model_id[0], context).name
|
||||||
self.title = model_desc
|
self.title = model_desc
|
||||||
datas['ids'] = ids
|
datas['ids'] = ids
|
||||||
result = model.fields_view_get(cr, uid, view_type='tree', context=context)
|
result = model.fields_view_get(cr, uid, view_type='tree', context=context)
|
||||||
|
@ -134,8 +134,9 @@ class report_printscreen_list(report_int):
|
||||||
_append_node('PageHeight', '%.2f' %(pageSize[1] * 2.8346,))
|
_append_node('PageHeight', '%.2f' %(pageSize[1] * 2.8346,))
|
||||||
_append_node('report-header', title)
|
_append_node('report-header', title)
|
||||||
|
|
||||||
_append_node('company', pooler.get_pool(self.cr.dbname).get('res.users').browse(self.cr,uid,uid).company_id.name)
|
registry = openerp.registry(self.cr.dbname)
|
||||||
rpt_obj = pooler.get_pool(self.cr.dbname).get('res.users')
|
_append_node('company', registry['res.users'].browse(self.cr,uid,uid).company_id.name)
|
||||||
|
rpt_obj = registry['res.users']
|
||||||
rml_obj=report_sxw.rml_parse(self.cr, uid, rpt_obj._name,context)
|
rml_obj=report_sxw.rml_parse(self.cr, uid, rpt_obj._name,context)
|
||||||
_append_node('header-date', str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")))
|
_append_node('header-date', str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")))
|
||||||
l = []
|
l = []
|
||||||
|
|
|
@ -29,10 +29,11 @@ import time
|
||||||
from interface import report_rml
|
from interface import report_rml
|
||||||
import preprocess
|
import preprocess
|
||||||
import logging
|
import logging
|
||||||
import openerp.pooler as pooler
|
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
import zipfile
|
import zipfile
|
||||||
import common
|
import common
|
||||||
|
|
||||||
|
import openerp
|
||||||
from openerp.osv.fields import float as float_field, function as function_field, datetime as datetime_field
|
from openerp.osv.fields import float as float_field, function as function_field, datetime as datetime_field
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
|
@ -152,8 +153,8 @@ class rml_parse(object):
|
||||||
context={}
|
context={}
|
||||||
self.cr = cr
|
self.cr = cr
|
||||||
self.uid = uid
|
self.uid = uid
|
||||||
self.pool = pooler.get_pool(cr.dbname)
|
self.pool = openerp.registry(cr.dbname)
|
||||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
user = self.pool['res.users'].browse(cr, uid, uid, context=context)
|
||||||
self.localcontext = {
|
self.localcontext = {
|
||||||
'user': user,
|
'user': user,
|
||||||
'setCompany': self.setCompany,
|
'setCompany': self.setCompany,
|
||||||
|
@ -220,7 +221,7 @@ class rml_parse(object):
|
||||||
model = 'ir.attachment'
|
model = 'ir.attachment'
|
||||||
try :
|
try :
|
||||||
id = int(id)
|
id = int(id)
|
||||||
res = self.pool.get(model).read(self.cr,self.uid,id)
|
res = self.pool[model].read(self.cr,self.uid,id)
|
||||||
if field :
|
if field :
|
||||||
return res[field]
|
return res[field]
|
||||||
elif model =='ir.attachment' :
|
elif model =='ir.attachment' :
|
||||||
|
@ -237,7 +238,7 @@ class rml_parse(object):
|
||||||
obj._context['lang'] = lang
|
obj._context['lang'] = lang
|
||||||
|
|
||||||
def _get_lang_dict(self):
|
def _get_lang_dict(self):
|
||||||
pool_lang = self.pool.get('res.lang')
|
pool_lang = self.pool['res.lang']
|
||||||
lang = self.localcontext.get('lang', 'en_US') or 'en_US'
|
lang = self.localcontext.get('lang', 'en_US') or 'en_US'
|
||||||
lang_ids = pool_lang.search(self.cr,self.uid,[('code','=',lang)])[0]
|
lang_ids = pool_lang.search(self.cr,self.uid,[('code','=',lang)])[0]
|
||||||
lang_obj = pool_lang.browse(self.cr,self.uid,lang_ids)
|
lang_obj = pool_lang.browse(self.cr,self.uid,lang_ids)
|
||||||
|
@ -252,7 +253,7 @@ class rml_parse(object):
|
||||||
def get_digits(self, obj=None, f=None, dp=None):
|
def get_digits(self, obj=None, f=None, dp=None):
|
||||||
d = DEFAULT_DIGITS = 2
|
d = DEFAULT_DIGITS = 2
|
||||||
if dp:
|
if dp:
|
||||||
decimal_precision_obj = self.pool.get('decimal.precision')
|
decimal_precision_obj = self.pool['decimal.precision']
|
||||||
ids = decimal_precision_obj.search(self.cr, self.uid, [('name', '=', dp)])
|
ids = decimal_precision_obj.search(self.cr, self.uid, [('name', '=', dp)])
|
||||||
if ids:
|
if ids:
|
||||||
d = decimal_precision_obj.browse(self.cr, self.uid, ids)[0].digits
|
d = decimal_precision_obj.browse(self.cr, self.uid, ids)[0].digits
|
||||||
|
@ -323,7 +324,7 @@ class rml_parse(object):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def display_address(self, address_browse_record):
|
def display_address(self, address_browse_record):
|
||||||
return self.pool.get('res.partner')._display_address(self.cr, self.uid, address_browse_record)
|
return self.pool['res.partner']._display_address(self.cr, self.uid, address_browse_record)
|
||||||
|
|
||||||
def repeatIn(self, lst, name,nodes_parent=False):
|
def repeatIn(self, lst, name,nodes_parent=False):
|
||||||
ret_lst = []
|
ret_lst = []
|
||||||
|
@ -334,7 +335,7 @@ class rml_parse(object):
|
||||||
def _translate(self,text):
|
def _translate(self,text):
|
||||||
lang = self.localcontext['lang']
|
lang = self.localcontext['lang']
|
||||||
if lang and text and not text.isspace():
|
if lang and text and not text.isspace():
|
||||||
transl_obj = self.pool.get('ir.translation')
|
transl_obj = self.pool['ir.translation']
|
||||||
piece_list = self._transl_regex.split(text)
|
piece_list = self._transl_regex.split(text)
|
||||||
for pn in range(len(piece_list)):
|
for pn in range(len(piece_list)):
|
||||||
if not self._transl_regex.match(piece_list[pn]):
|
if not self._transl_regex.match(piece_list[pn]):
|
||||||
|
@ -399,7 +400,7 @@ class report_sxw(report_rml, preprocess.report):
|
||||||
self.internal_header=True
|
self.internal_header=True
|
||||||
|
|
||||||
def getObjects(self, cr, uid, ids, context):
|
def getObjects(self, cr, uid, ids, context):
|
||||||
table_obj = pooler.get_pool(cr.dbname).get(self.table)
|
table_obj = openerp.registry(cr.dbname)[self.table]
|
||||||
return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context, fields_process=_fields_process)
|
return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context, fields_process=_fields_process)
|
||||||
|
|
||||||
def create(self, cr, uid, ids, data, context=None):
|
def create(self, cr, uid, ids, data, context=None):
|
||||||
|
@ -409,8 +410,8 @@ class report_sxw(report_rml, preprocess.report):
|
||||||
context.update(internal_header=self.internal_header)
|
context.update(internal_header=self.internal_header)
|
||||||
# skip osv.fields.sanitize_binary_value() because we want the raw bytes in all cases
|
# skip osv.fields.sanitize_binary_value() because we want the raw bytes in all cases
|
||||||
context.update(bin_raw=True)
|
context.update(bin_raw=True)
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
ir_obj = pool.get('ir.actions.report.xml')
|
ir_obj = registry['ir.actions.report.xml']
|
||||||
report_xml_ids = ir_obj.search(cr, uid,
|
report_xml_ids = ir_obj.search(cr, uid,
|
||||||
[('report_name', '=', self.name[7:])], context=context)
|
[('report_name', '=', self.name[7:])], context=context)
|
||||||
if report_xml_ids:
|
if report_xml_ids:
|
||||||
|
@ -458,7 +459,7 @@ class report_sxw(report_rml, preprocess.report):
|
||||||
def create_source_pdf(self, cr, uid, ids, data, report_xml, context=None):
|
def create_source_pdf(self, cr, uid, ids, data, report_xml, context=None):
|
||||||
if not context:
|
if not context:
|
||||||
context={}
|
context={}
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
attach = report_xml.attachment
|
attach = report_xml.attachment
|
||||||
if attach:
|
if attach:
|
||||||
objs = self.getObjects(cr, uid, ids, context)
|
objs = self.getObjects(cr, uid, ids, context)
|
||||||
|
@ -467,9 +468,9 @@ class report_sxw(report_rml, preprocess.report):
|
||||||
aname = eval(attach, {'object':obj, 'time':time})
|
aname = eval(attach, {'object':obj, 'time':time})
|
||||||
result = False
|
result = False
|
||||||
if report_xml.attachment_use and aname and context.get('attachment_use', True):
|
if report_xml.attachment_use and aname and context.get('attachment_use', True):
|
||||||
aids = pool.get('ir.attachment').search(cr, uid, [('datas_fname','=',aname+'.pdf'),('res_model','=',self.table),('res_id','=',obj.id)])
|
aids = registry['ir.attachment'].search(cr, uid, [('datas_fname','=',aname+'.pdf'),('res_model','=',self.table),('res_id','=',obj.id)])
|
||||||
if aids:
|
if aids:
|
||||||
brow_rec = pool.get('ir.attachment').browse(cr, uid, aids[0])
|
brow_rec = registry['ir.attachment'].browse(cr, uid, aids[0])
|
||||||
if not brow_rec.datas:
|
if not brow_rec.datas:
|
||||||
continue
|
continue
|
||||||
d = base64.decodestring(brow_rec.datas)
|
d = base64.decodestring(brow_rec.datas)
|
||||||
|
@ -487,7 +488,7 @@ class report_sxw(report_rml, preprocess.report):
|
||||||
# field.
|
# field.
|
||||||
ctx = dict(context)
|
ctx = dict(context)
|
||||||
ctx.pop('default_type', None)
|
ctx.pop('default_type', None)
|
||||||
pool.get('ir.attachment').create(cr, uid, {
|
registry['ir.attachment'].create(cr, uid, {
|
||||||
'name': aname,
|
'name': aname,
|
||||||
'datas': base64.encodestring(result[0]),
|
'datas': base64.encodestring(result[0]),
|
||||||
'datas_fname': name,
|
'datas_fname': name,
|
||||||
|
|
|
@ -4,7 +4,6 @@ import logging
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import openerp.osv.orm # TODO use openerp.exceptions
|
import openerp.osv.orm # TODO use openerp.exceptions
|
||||||
import openerp.pooler
|
|
||||||
import openerp.release
|
import openerp.release
|
||||||
import openerp.tools
|
import openerp.tools
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ def exp_login(db, login, password):
|
||||||
return res or False
|
return res or False
|
||||||
|
|
||||||
def exp_authenticate(db, login, password, user_agent_env):
|
def exp_authenticate(db, login, password, user_agent_env):
|
||||||
res_users = openerp.pooler.get_pool(db).get('res.users')
|
res_users = openerp.registry(db)['res.users']
|
||||||
return res_users.authenticate(db, login, password, user_agent_env)
|
return res_users.authenticate(db, login, password, user_agent_env)
|
||||||
|
|
||||||
def exp_version():
|
def exp_version():
|
||||||
|
|
|
@ -7,8 +7,8 @@ import os
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import openerp
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
import openerp.pooler
|
|
||||||
import openerp.release
|
import openerp.release
|
||||||
import openerp.sql_db
|
import openerp.sql_db
|
||||||
import openerp.tools
|
import openerp.tools
|
||||||
|
@ -28,7 +28,7 @@ def _initialize_db(id, db_name, demo, lang, user_password):
|
||||||
try:
|
try:
|
||||||
self_actions[id]['progress'] = 0
|
self_actions[id]['progress'] = 0
|
||||||
cr = openerp.sql_db.db_connect(db_name).cursor()
|
cr = openerp.sql_db.db_connect(db_name).cursor()
|
||||||
openerp.modules.db.initialize(cr) # TODO this should be removed as it is done by pooler.restart_pool.
|
openerp.modules.db.initialize(cr) # TODO this should be removed as it is done by RegistryManager.new().
|
||||||
openerp.tools.config['lang'] = lang
|
openerp.tools.config['lang'] = lang
|
||||||
cr.commit()
|
cr.commit()
|
||||||
finally:
|
finally:
|
||||||
|
@ -36,20 +36,20 @@ def _initialize_db(id, db_name, demo, lang, user_password):
|
||||||
cr.close()
|
cr.close()
|
||||||
cr = None
|
cr = None
|
||||||
|
|
||||||
pool = openerp.pooler.restart_pool(db_name, demo, self_actions[id],
|
registry = openerp.modules.registry.RegistryManager.new(
|
||||||
update_module=True)[1]
|
db_name, demo, self_actions[id], update_module=True)[1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cr = openerp.sql_db.db_connect(db_name).cursor()
|
cr = openerp.sql_db.db_connect(db_name).cursor()
|
||||||
|
|
||||||
if lang:
|
if lang:
|
||||||
modobj = pool.get('ir.module.module')
|
modobj = registry['ir.module.module']
|
||||||
mids = modobj.search(cr, SUPERUSER_ID, [('state', '=', 'installed')])
|
mids = modobj.search(cr, SUPERUSER_ID, [('state', '=', 'installed')])
|
||||||
modobj.update_translations(cr, SUPERUSER_ID, mids, lang)
|
modobj.update_translations(cr, SUPERUSER_ID, mids, lang)
|
||||||
|
|
||||||
# update admin's password and lang
|
# update admin's password and lang
|
||||||
values = {'password': user_password, 'lang': lang}
|
values = {'password': user_password, 'lang': lang}
|
||||||
pool.get('res.users').write(cr, SUPERUSER_ID, [SUPERUSER_ID], values)
|
registry['res.users'].write(cr, SUPERUSER_ID, [SUPERUSER_ID], values)
|
||||||
|
|
||||||
cr.execute('SELECT login, password FROM res_users ORDER BY login')
|
cr.execute('SELECT login, password FROM res_users ORDER BY login')
|
||||||
self_actions[id].update(users=cr.dictfetchall(), clean=True)
|
self_actions[id].update(users=cr.dictfetchall(), clean=True)
|
||||||
|
@ -351,7 +351,7 @@ def exp_migrate_databases(databases):
|
||||||
for db in databases:
|
for db in databases:
|
||||||
_logger.info('migrate database %s', db)
|
_logger.info('migrate database %s', db)
|
||||||
openerp.tools.config['update']['base'] = True
|
openerp.tools.config['update']['base'] = True
|
||||||
openerp.pooler.restart_pool(db, force_demo=False, update_module=True)
|
openerp.modules.registry.RegistryManager.new(db, force_demo=False, update_module=True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -61,7 +61,7 @@ def check(f):
|
||||||
# callable. We need to find the right parameters to call
|
# callable. We need to find the right parameters to call
|
||||||
# the orm._sql_message(self, cr, uid, ids, context) function,
|
# the orm._sql_message(self, cr, uid, ids, context) function,
|
||||||
# or we skip..
|
# or we skip..
|
||||||
# our signature is f(osv_pool, dbname [,uid, obj, method, args])
|
# our signature is f(registry, dbname [,uid, obj, method, args])
|
||||||
try:
|
try:
|
||||||
if args and len(args) > 1:
|
if args and len(args) > 1:
|
||||||
# TODO self doesn't exist, but was already wrong before (it was not a registry but just the object_service.
|
# TODO self doesn't exist, but was already wrong before (it was not a registry but just the object_service.
|
||||||
|
@ -95,14 +95,14 @@ def check(f):
|
||||||
return tr(src, 'code')
|
return tr(src, 'code')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if openerp.pooler.get_pool(dbname)._init:
|
if openerp.registry(dbname)._init:
|
||||||
raise openerp.exceptions.Warning('Currently, this database is not fully loaded and can not be used.')
|
raise openerp.exceptions.Warning('Currently, this database is not fully loaded and can not be used.')
|
||||||
return f(dbname, *args, **kwargs)
|
return f(dbname, *args, **kwargs)
|
||||||
except IntegrityError, inst:
|
except IntegrityError, inst:
|
||||||
osv_pool = openerp.pooler.get_pool(dbname)
|
registry = openerp.registry(dbname)
|
||||||
for key in osv_pool._sql_error.keys():
|
for key in registry._sql_error.keys():
|
||||||
if key in inst[0]:
|
if key in inst[0]:
|
||||||
raise openerp.osv.orm.except_orm(_('Constraint Error'), tr(osv_pool._sql_error[key], 'sql_constraint') or inst[0])
|
raise openerp.osv.orm.except_orm(_('Constraint Error'), tr(registry._sql_error[key], 'sql_constraint') or inst[0])
|
||||||
if inst.pgcode in (errorcodes.NOT_NULL_VIOLATION, errorcodes.FOREIGN_KEY_VIOLATION, errorcodes.RESTRICT_VIOLATION):
|
if inst.pgcode in (errorcodes.NOT_NULL_VIOLATION, errorcodes.FOREIGN_KEY_VIOLATION, errorcodes.RESTRICT_VIOLATION):
|
||||||
msg = _('The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set')
|
msg = _('The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set')
|
||||||
_logger.debug("IntegrityError", exc_info=True)
|
_logger.debug("IntegrityError", exc_info=True)
|
||||||
|
@ -116,7 +116,7 @@ def check(f):
|
||||||
last_quote_begin = errortxt.rfind('"', 0, last_quote_end)
|
last_quote_begin = errortxt.rfind('"', 0, last_quote_end)
|
||||||
model_name = table = errortxt[last_quote_begin+1:last_quote_end].strip()
|
model_name = table = errortxt[last_quote_begin+1:last_quote_end].strip()
|
||||||
model = table.replace("_",".")
|
model = table.replace("_",".")
|
||||||
model_obj = osv_pool.get(model)
|
model_obj = registry.get(model)
|
||||||
if model_obj:
|
if model_obj:
|
||||||
model_name = model_obj._description or model_obj._name
|
model_name = model_obj._description or model_obj._name
|
||||||
msg += _('\n\n[object with reference: %s - %s]') % (model_name, model)
|
msg += _('\n\n[object with reference: %s - %s]') % (model_name, model)
|
||||||
|
@ -129,7 +129,7 @@ def check(f):
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def execute_cr(cr, uid, obj, method, *args, **kw):
|
def execute_cr(cr, uid, obj, method, *args, **kw):
|
||||||
object = openerp.pooler.get_pool(cr.dbname).get(obj)
|
object = openerp.registry(cr.dbname).get(obj)
|
||||||
if not object:
|
if not object:
|
||||||
raise except_orm('Object Error', 'Object %s doesn\'t exist' % str(obj))
|
raise except_orm('Object Error', 'Object %s doesn\'t exist' % str(obj))
|
||||||
return getattr(object, method)(cr, uid, *args, **kw)
|
return getattr(object, method)(cr, uid, *args, **kw)
|
||||||
|
@ -140,7 +140,7 @@ def execute_kw(db, uid, obj, method, args, kw=None):
|
||||||
@check
|
@check
|
||||||
def execute(db, uid, obj, method, *args, **kw):
|
def execute(db, uid, obj, method, *args, **kw):
|
||||||
threading.currentThread().dbname = db
|
threading.currentThread().dbname = db
|
||||||
cr = openerp.pooler.get_db(db).cursor()
|
cr = openerp.registry(db).db.cursor()
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
if method.startswith('_'):
|
if method.startswith('_'):
|
||||||
|
@ -157,7 +157,7 @@ def execute(db, uid, obj, method, *args, **kw):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def exec_workflow_cr(cr, uid, obj, signal, *args):
|
def exec_workflow_cr(cr, uid, obj, signal, *args):
|
||||||
object = openerp.pooler.get_pool(cr.dbname).get(obj)
|
object = openerp.registry(cr.dbname).get(obj)
|
||||||
if not object:
|
if not object:
|
||||||
raise except_orm('Object Error', 'Object %s doesn\'t exist' % str(obj))
|
raise except_orm('Object Error', 'Object %s doesn\'t exist' % str(obj))
|
||||||
res_id = args[0]
|
res_id = args[0]
|
||||||
|
@ -165,7 +165,7 @@ def exec_workflow_cr(cr, uid, obj, signal, *args):
|
||||||
|
|
||||||
@check
|
@check
|
||||||
def exec_workflow(db, uid, obj, signal, *args):
|
def exec_workflow(db, uid, obj, signal, *args):
|
||||||
cr = openerp.pooler.get_db(db).cursor()
|
cr = openerp.registry(db).db.cursor()
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
res = exec_workflow_cr(cr, uid, obj, signal, *args)
|
res = exec_workflow_cr(cr, uid, obj, signal, *args)
|
||||||
|
|
|
@ -5,8 +5,8 @@ import logging
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
import openerp
|
||||||
import openerp.netsvc
|
import openerp.netsvc
|
||||||
import openerp.pooler
|
|
||||||
from openerp import tools
|
from openerp import tools
|
||||||
|
|
||||||
import security
|
import security
|
||||||
|
@ -49,7 +49,7 @@ def exp_render_report(db, uid, object, ids, datas=None, context=None):
|
||||||
|
|
||||||
self_reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None}
|
self_reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None}
|
||||||
|
|
||||||
cr = openerp.pooler.get_db(db).cursor()
|
cr = openerp.registry(db).db.cursor()
|
||||||
try:
|
try:
|
||||||
obj = openerp.netsvc.LocalService('report.'+object)
|
obj = openerp.netsvc.LocalService('report.'+object)
|
||||||
(result, format) = obj.create(cr, uid, ids, datas, context)
|
(result, format) = obj.create(cr, uid, ids, datas, context)
|
||||||
|
@ -88,7 +88,7 @@ def exp_report(db, uid, object, ids, datas=None, context=None):
|
||||||
self_reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None}
|
self_reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None}
|
||||||
|
|
||||||
def go(id, uid, ids, datas, context):
|
def go(id, uid, ids, datas, context):
|
||||||
cr = openerp.pooler.get_db(db).cursor()
|
cr = openerp.registry(db).db.cursor()
|
||||||
try:
|
try:
|
||||||
obj = openerp.netsvc.LocalService('report.'+object)
|
obj = openerp.netsvc.LocalService('report.'+object)
|
||||||
(result, format) = obj.create(cr, uid, ids, datas, context)
|
(result, format) = obj.create(cr, uid, ids, datas, context)
|
||||||
|
|
|
@ -19,25 +19,20 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import openerp.exceptions
|
import openerp
|
||||||
import openerp.pooler as pooler
|
|
||||||
import openerp.tools as tools
|
|
||||||
|
|
||||||
|
|
||||||
def login(db, login, password):
|
def login(db, login, password):
|
||||||
pool = pooler.get_pool(db)
|
res_users = openerp.registry(db)['res.users']
|
||||||
user_obj = pool.get('res.users')
|
return res_users.login(db, login, password)
|
||||||
return user_obj.login(db, login, password)
|
|
||||||
|
|
||||||
def check_super(passwd):
|
def check_super(passwd):
|
||||||
if passwd == tools.config['admin_passwd']:
|
if passwd == openerp.tools.config['admin_passwd']:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
raise openerp.exceptions.AccessDenied()
|
raise openerp.exceptions.AccessDenied()
|
||||||
|
|
||||||
def check(db, uid, passwd):
|
def check(db, uid, passwd):
|
||||||
pool = pooler.get_pool(db)
|
res_users = openerp.registry(db)['res.users']
|
||||||
user_obj = pool.get('res.users')
|
return res_users.check(db, uid, passwd)
|
||||||
return user_obj.check(db, uid, passwd)
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
The PostgreSQL connector is a connectivity layer between the OpenERP code and
|
The PostgreSQL connector is a connectivity layer between the OpenERP code and
|
||||||
the database, *not* a database abstraction toolkit. Database abstraction is what
|
the database, *not* a database abstraction toolkit. Database abstraction is what
|
||||||
the ORM does, in fact.
|
the ORM does, in fact.
|
||||||
|
|
||||||
See also: the `pooler` module
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import sys
|
||||||
|
|
||||||
# for eval context:
|
# for eval context:
|
||||||
import time
|
import time
|
||||||
|
import openerp
|
||||||
import openerp.release as release
|
import openerp.release as release
|
||||||
|
|
||||||
import assertion_report
|
import assertion_report
|
||||||
|
@ -47,7 +48,6 @@ except:
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import misc
|
import misc
|
||||||
import openerp.pooler as pooler
|
|
||||||
from config import config
|
from config import config
|
||||||
from translate import _
|
from translate import _
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ def _ref(self, cr):
|
||||||
return lambda x: self.id_get(cr, x)
|
return lambda x: self.id_get(cr, x)
|
||||||
|
|
||||||
def _obj(pool, cr, uid, model_str, context=None):
|
def _obj(pool, cr, uid, model_str, context=None):
|
||||||
model = pool.get(model_str)
|
model = pool[model_str]
|
||||||
return lambda x: model.browse(cr, uid, x, context=context)
|
return lambda x: model.browse(cr, uid, x, context=context)
|
||||||
|
|
||||||
def _get_idref(self, cr, uid, model_str, context, idref):
|
def _get_idref(self, cr, uid, model_str, context, idref):
|
||||||
|
@ -124,10 +124,10 @@ def _eval_xml(self, node, pool, cr, uid, idref, context=None):
|
||||||
if f_search:
|
if f_search:
|
||||||
idref2 = _get_idref(self, cr, uid, f_model, context, idref)
|
idref2 = _get_idref(self, cr, uid, f_model, context, idref)
|
||||||
q = unsafe_eval(f_search, idref2)
|
q = unsafe_eval(f_search, idref2)
|
||||||
ids = pool.get(f_model).search(cr, uid, q)
|
ids = pool[f_model].search(cr, uid, q)
|
||||||
if f_use != 'id':
|
if f_use != 'id':
|
||||||
ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use]))
|
ids = map(lambda x: x[f_use], pool[f_model].read(cr, uid, ids, [f_use]))
|
||||||
_cols = pool.get(f_model)._columns
|
_cols = pool[f_model]._columns
|
||||||
if (f_name in _cols) and _cols[f_name]._type=='many2many':
|
if (f_name in _cols) and _cols[f_name]._type=='many2many':
|
||||||
return ids
|
return ids
|
||||||
f_val = False
|
f_val = False
|
||||||
|
@ -196,7 +196,7 @@ def _eval_xml(self, node, pool, cr, uid, idref, context=None):
|
||||||
return_val = _eval_xml(self,n, pool, cr, uid, idref, context)
|
return_val = _eval_xml(self,n, pool, cr, uid, idref, context)
|
||||||
if return_val is not None:
|
if return_val is not None:
|
||||||
args.append(return_val)
|
args.append(return_val)
|
||||||
model = pool.get(node.get('model',''))
|
model = pool[node.get('model','')]
|
||||||
method = node.get('name','')
|
method = node.get('name','')
|
||||||
res = getattr(model, method)(cr, uid, *args)
|
res = getattr(model, method)(cr, uid, *args)
|
||||||
return res
|
return res
|
||||||
|
@ -256,7 +256,7 @@ class xml_import(object):
|
||||||
maximum one dot. They are used to refer to other modules ID, in the
|
maximum one dot. They are used to refer to other modules ID, in the
|
||||||
form: module.record_id""" % (xml_id,)
|
form: module.record_id""" % (xml_id,)
|
||||||
if module != self.module:
|
if module != self.module:
|
||||||
modcnt = self.pool.get('ir.module.module').search_count(self.cr, self.uid, ['&', ('name', '=', module), ('state', 'in', ['installed'])])
|
modcnt = self.pool['ir.module.module'].search_count(self.cr, self.uid, ['&', ('name', '=', module), ('state', 'in', ['installed'])])
|
||||||
assert modcnt == 1, """The ID "%s" refers to an uninstalled module""" % (xml_id,)
|
assert modcnt == 1, """The ID "%s" refers to an uninstalled module""" % (xml_id,)
|
||||||
|
|
||||||
if len(id) > 64:
|
if len(id) > 64:
|
||||||
|
@ -270,7 +270,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
|
|
||||||
if d_search:
|
if d_search:
|
||||||
idref = _get_idref(self, cr, self.uid, d_model, context={}, idref={})
|
idref = _get_idref(self, cr, self.uid, d_model, context={}, idref={})
|
||||||
ids = self.pool.get(d_model).search(cr, self.uid, unsafe_eval(d_search, idref))
|
ids = self.pool[d_model].search(cr, self.uid, unsafe_eval(d_search, idref))
|
||||||
if d_id:
|
if d_id:
|
||||||
try:
|
try:
|
||||||
ids.append(self.id_get(cr, d_id))
|
ids.append(self.id_get(cr, d_id))
|
||||||
|
@ -278,10 +278,10 @@ form: module.record_id""" % (xml_id,)
|
||||||
# d_id cannot be found. doesn't matter in this case
|
# d_id cannot be found. doesn't matter in this case
|
||||||
pass
|
pass
|
||||||
if ids:
|
if ids:
|
||||||
self.pool.get(d_model).unlink(cr, self.uid, ids)
|
self.pool[d_model].unlink(cr, self.uid, ids)
|
||||||
|
|
||||||
def _remove_ir_values(self, cr, name, value, model):
|
def _remove_ir_values(self, cr, name, value, model):
|
||||||
ir_values_obj = self.pool.get('ir.values')
|
ir_values_obj = self.pool['ir.values']
|
||||||
ir_value_ids = ir_values_obj.search(cr, self.uid, [('name','=',name),('value','=',value),('model','=',model)])
|
ir_value_ids = ir_values_obj.search(cr, self.uid, [('name','=',name),('value','=',value),('model','=',model)])
|
||||||
if ir_value_ids:
|
if ir_value_ids:
|
||||||
ir_values_obj.unlink(cr, self.uid, ir_value_ids)
|
ir_values_obj.unlink(cr, self.uid, ir_value_ids)
|
||||||
|
@ -324,14 +324,14 @@ form: module.record_id""" % (xml_id,)
|
||||||
groups_value.append((4, group_id))
|
groups_value.append((4, group_id))
|
||||||
res['groups_id'] = groups_value
|
res['groups_id'] = groups_value
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
|
id = self.pool['ir.model.data']._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
|
||||||
self.idref[xml_id] = int(id)
|
self.idref[xml_id] = int(id)
|
||||||
|
|
||||||
if not rec.get('menu') or eval(rec.get('menu','False')):
|
if not rec.get('menu') or eval(rec.get('menu','False')):
|
||||||
keyword = str(rec.get('keyword', 'client_print_multi'))
|
keyword = str(rec.get('keyword', 'client_print_multi'))
|
||||||
value = 'ir.actions.report.xml,'+str(id)
|
value = 'ir.actions.report.xml,'+str(id)
|
||||||
replace = rec.get('replace', True)
|
replace = rec.get('replace', True)
|
||||||
self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, res['name'], [res['model']], value, replace=replace, isobject=True, xml_id=xml_id)
|
self.pool['ir.model.data'].ir_set(cr, self.uid, 'action', keyword, res['name'], [res['model']], value, replace=replace, isobject=True, xml_id=xml_id)
|
||||||
elif self.mode=='update' and eval(rec.get('menu','False'))==False:
|
elif self.mode=='update' and eval(rec.get('menu','False'))==False:
|
||||||
# Special check for report having attribute menu=False on update
|
# Special check for report having attribute menu=False on update
|
||||||
value = 'ir.actions.report.xml,'+str(id)
|
value = 'ir.actions.report.xml,'+str(id)
|
||||||
|
@ -367,14 +367,14 @@ form: module.record_id""" % (xml_id,)
|
||||||
groups_value.append((4, group_id))
|
groups_value.append((4, group_id))
|
||||||
res['groups_id'] = groups_value
|
res['groups_id'] = groups_value
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.wizard", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
|
id = self.pool['ir.model.data']._update(cr, self.uid, "ir.actions.wizard", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
|
||||||
self.idref[xml_id] = int(id)
|
self.idref[xml_id] = int(id)
|
||||||
# ir_set
|
# ir_set
|
||||||
if (not rec.get('menu') or eval(rec.get('menu','False'))) and id:
|
if (not rec.get('menu') or eval(rec.get('menu','False'))) and id:
|
||||||
keyword = str(rec.get('keyword','') or 'client_action_multi')
|
keyword = str(rec.get('keyword','') or 'client_action_multi')
|
||||||
value = 'ir.actions.wizard,'+str(id)
|
value = 'ir.actions.wizard,'+str(id)
|
||||||
replace = rec.get("replace",'') or True
|
replace = rec.get("replace",'') or True
|
||||||
self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, string, [model], value, replace=replace, isobject=True, xml_id=xml_id)
|
self.pool['ir.model.data'].ir_set(cr, self.uid, 'action', keyword, string, [model], value, replace=replace, isobject=True, xml_id=xml_id)
|
||||||
elif self.mode=='update' and (rec.get('menu') and eval(rec.get('menu','False'))==False):
|
elif self.mode=='update' and (rec.get('menu') and eval(rec.get('menu','False'))==False):
|
||||||
# Special check for wizard having attribute menu=False on update
|
# Special check for wizard having attribute menu=False on update
|
||||||
value = 'ir.actions.wizard,'+str(id)
|
value = 'ir.actions.wizard,'+str(id)
|
||||||
|
@ -389,7 +389,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
|
|
||||||
res = {'name': name, 'url': url, 'target':target}
|
res = {'name': name, 'url': url, 'target':target}
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.act_url", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
|
id = self.pool['ir.model.data']._update(cr, self.uid, "ir.actions.act_url", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
|
||||||
self.idref[xml_id] = int(id)
|
self.idref[xml_id] = int(id)
|
||||||
|
|
||||||
def _tag_act_window(self, cr, rec, data_node=None):
|
def _tag_act_window(self, cr, rec, data_node=None):
|
||||||
|
@ -489,7 +489,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
res['target'] = rec.get('target','')
|
res['target'] = rec.get('target','')
|
||||||
if rec.get('multi'):
|
if rec.get('multi'):
|
||||||
res['multi'] = rec.get('multi', False)
|
res['multi'] = rec.get('multi', False)
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.actions.act_window', self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
|
id = self.pool['ir.model.data']._update(cr, self.uid, 'ir.actions.act_window', self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
|
||||||
self.idref[xml_id] = int(id)
|
self.idref[xml_id] = int(id)
|
||||||
|
|
||||||
if src_model:
|
if src_model:
|
||||||
|
@ -497,7 +497,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
keyword = rec.get('key2','').encode('utf-8') or 'client_action_relate'
|
keyword = rec.get('key2','').encode('utf-8') or 'client_action_relate'
|
||||||
value = 'ir.actions.act_window,'+str(id)
|
value = 'ir.actions.act_window,'+str(id)
|
||||||
replace = rec.get('replace','') or True
|
replace = rec.get('replace','') or True
|
||||||
self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, xml_id, [src_model], value, replace=replace, isobject=True, xml_id=xml_id)
|
self.pool['ir.model.data'].ir_set(cr, self.uid, 'action', keyword, xml_id, [src_model], value, replace=replace, isobject=True, xml_id=xml_id)
|
||||||
# TODO add remove ir.model.data
|
# TODO add remove ir.model.data
|
||||||
|
|
||||||
def _tag_ir_set(self, cr, rec, data_node=None):
|
def _tag_ir_set(self, cr, rec, data_node=None):
|
||||||
|
@ -508,7 +508,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
f_name = field.get("name",'').encode('utf-8')
|
f_name = field.get("name",'').encode('utf-8')
|
||||||
f_val = _eval_xml(self,field,self.pool, cr, self.uid, self.idref)
|
f_val = _eval_xml(self,field,self.pool, cr, self.uid, self.idref)
|
||||||
res[f_name] = f_val
|
res[f_name] = f_val
|
||||||
self.pool.get('ir.model.data').ir_set(cr, self.uid, res['key'], res['key2'], res['name'], res['models'], res['value'], replace=res.get('replace',True), isobject=res.get('isobject', False), meta=res.get('meta',None))
|
self.pool['ir.model.data'].ir_set(cr, self.uid, res['key'], res['key2'], res['name'], res['models'], res['value'], replace=res.get('replace',True), isobject=res.get('isobject', False), meta=res.get('meta',None))
|
||||||
|
|
||||||
def _tag_workflow(self, cr, rec, data_node=None):
|
def _tag_workflow(self, cr, rec, data_node=None):
|
||||||
if self.isnoupdate(data_node) and self.mode != 'init':
|
if self.isnoupdate(data_node) and self.mode != 'init':
|
||||||
|
@ -563,7 +563,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
else:
|
else:
|
||||||
# the menuitem does't exist but we are in branch (not a leaf)
|
# the menuitem does't exist but we are in branch (not a leaf)
|
||||||
_logger.warning('Warning no ID for submenu %s of menu %s !', menu_elem, str(m_l))
|
_logger.warning('Warning no ID for submenu %s of menu %s !', menu_elem, str(m_l))
|
||||||
pid = self.pool.get('ir.ui.menu').create(cr, self.uid, {'parent_id' : pid, 'name' : menu_elem})
|
pid = self.pool['ir.ui.menu'].create(cr, self.uid, {'parent_id' : pid, 'name' : menu_elem})
|
||||||
values['parent_id'] = pid
|
values['parent_id'] = pid
|
||||||
else:
|
else:
|
||||||
# The parent attribute was specified, if non-empty determine its ID, otherwise
|
# The parent attribute was specified, if non-empty determine its ID, otherwise
|
||||||
|
@ -657,14 +657,14 @@ form: module.record_id""" % (xml_id,)
|
||||||
groups_value.append((4, group_id))
|
groups_value.append((4, group_id))
|
||||||
values['groups_id'] = groups_value
|
values['groups_id'] = groups_value
|
||||||
|
|
||||||
pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, rec_id, noupdate=self.isnoupdate(data_node), mode=self.mode, res_id=res and res[0] or False)
|
pid = self.pool['ir.model.data']._update(cr, self.uid, 'ir.ui.menu', self.module, values, rec_id, noupdate=self.isnoupdate(data_node), mode=self.mode, res_id=res and res[0] or False)
|
||||||
|
|
||||||
if rec_id and pid:
|
if rec_id and pid:
|
||||||
self.idref[rec_id] = int(pid)
|
self.idref[rec_id] = int(pid)
|
||||||
|
|
||||||
if rec.get('action') and pid:
|
if rec.get('action') and pid:
|
||||||
action = "ir.actions.%s,%d" % (a_type, a_id)
|
action = "ir.actions.%s,%d" % (a_type, a_id)
|
||||||
self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(pid))], action, True, True, xml_id=rec_id)
|
self.pool['ir.model.data'].ir_set(cr, self.uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(pid))], action, True, True, xml_id=rec_id)
|
||||||
return 'ir.ui.menu', pid
|
return 'ir.ui.menu', pid
|
||||||
|
|
||||||
def _assert_equals(self, f1, f2, prec=4):
|
def _assert_equals(self, f1, f2, prec=4):
|
||||||
|
@ -675,8 +675,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
return
|
return
|
||||||
|
|
||||||
rec_model = rec.get("model",'').encode('ascii')
|
rec_model = rec.get("model",'').encode('ascii')
|
||||||
model = self.pool.get(rec_model)
|
model = self.pool[rec_model]
|
||||||
assert model, "The model %s does not exist !" % (rec_model,)
|
|
||||||
rec_id = rec.get("id",'').encode('ascii')
|
rec_id = rec.get("id",'').encode('ascii')
|
||||||
self._test_xml_id(rec_id)
|
self._test_xml_id(rec_id)
|
||||||
rec_src = rec.get("search",'').encode('utf8')
|
rec_src = rec.get("search",'').encode('utf8')
|
||||||
|
@ -692,7 +691,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
ids = [self.id_get(cr, rec_id)]
|
ids = [self.id_get(cr, rec_id)]
|
||||||
elif rec_src:
|
elif rec_src:
|
||||||
q = unsafe_eval(rec_src, eval_dict)
|
q = unsafe_eval(rec_src, eval_dict)
|
||||||
ids = self.pool.get(rec_model).search(cr, uid, q, context=context)
|
ids = self.pool[rec_model].search(cr, uid, q, context=context)
|
||||||
if rec_src_count:
|
if rec_src_count:
|
||||||
count = int(rec_src_count)
|
count = int(rec_src_count)
|
||||||
if len(ids) != count:
|
if len(ids) != count:
|
||||||
|
@ -737,8 +736,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
|
|
||||||
def _tag_record(self, cr, rec, data_node=None):
|
def _tag_record(self, cr, rec, data_node=None):
|
||||||
rec_model = rec.get("model").encode('ascii')
|
rec_model = rec.get("model").encode('ascii')
|
||||||
model = self.pool.get(rec_model)
|
model = self.pool[rec_model]
|
||||||
assert model, "The model %s does not exist !" % (rec_model,)
|
|
||||||
rec_id = rec.get("id",'').encode('ascii')
|
rec_id = rec.get("id",'').encode('ascii')
|
||||||
rec_context = rec.get("context", None)
|
rec_context = rec.get("context", None)
|
||||||
if rec_context:
|
if rec_context:
|
||||||
|
@ -752,7 +750,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
else:
|
else:
|
||||||
module = self.module
|
module = self.module
|
||||||
rec_id2 = rec_id
|
rec_id2 = rec_id
|
||||||
id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2)
|
id = self.pool['ir.model.data']._update_dummy(cr, self.uid, rec_model, module, rec_id2)
|
||||||
# check if the resource already existed at the last update
|
# check if the resource already existed at the last update
|
||||||
if id:
|
if id:
|
||||||
# if it existed, we don't update the data, but we need to
|
# if it existed, we don't update the data, but we need to
|
||||||
|
@ -785,11 +783,11 @@ form: module.record_id""" % (xml_id,)
|
||||||
q = unsafe_eval(f_search, self.idref)
|
q = unsafe_eval(f_search, self.idref)
|
||||||
field = []
|
field = []
|
||||||
assert f_model, 'Define an attribute model="..." in your .XML file !'
|
assert f_model, 'Define an attribute model="..." in your .XML file !'
|
||||||
f_obj = self.pool.get(f_model)
|
f_obj = self.pool[f_model]
|
||||||
# browse the objects searched
|
# browse the objects searched
|
||||||
s = f_obj.browse(cr, self.uid, f_obj.search(cr, self.uid, q))
|
s = f_obj.browse(cr, self.uid, f_obj.search(cr, self.uid, q))
|
||||||
# column definitions of the "local" object
|
# column definitions of the "local" object
|
||||||
_cols = self.pool.get(rec_model)._columns
|
_cols = self.pool[rec_model]._columns
|
||||||
# if the current field is many2many
|
# if the current field is many2many
|
||||||
if (f_name in _cols) and _cols[f_name]._type=='many2many':
|
if (f_name in _cols) and _cols[f_name]._type=='many2many':
|
||||||
f_val = [(6, 0, map(lambda x: x[f_use], s))]
|
f_val = [(6, 0, map(lambda x: x[f_use], s))]
|
||||||
|
@ -815,7 +813,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
f_val = int(f_val)
|
f_val = int(f_val)
|
||||||
res[f_name] = f_val
|
res[f_name] = f_val
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
|
id = self.pool['ir.model.data']._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
|
||||||
if rec_id:
|
if rec_id:
|
||||||
self.idref[rec_id] = int(id)
|
self.idref[rec_id] = int(id)
|
||||||
if config.get('import_partial', False):
|
if config.get('import_partial', False):
|
||||||
|
@ -830,7 +828,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def model_id_get(self, cr, id_str):
|
def model_id_get(self, cr, id_str):
|
||||||
model_data_obj = self.pool.get('ir.model.data')
|
model_data_obj = self.pool['ir.model.data']
|
||||||
mod = self.module
|
mod = self.module
|
||||||
if '.' in id_str:
|
if '.' in id_str:
|
||||||
mod,id_str = id_str.split('.')
|
mod,id_str = id_str.split('.')
|
||||||
|
@ -857,7 +855,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
self.module = module
|
self.module = module
|
||||||
self.cr = cr
|
self.cr = cr
|
||||||
self.idref = idref
|
self.idref = idref
|
||||||
self.pool = pooler.get_pool(cr.dbname)
|
self.pool = openerp.registry(cr.dbname)
|
||||||
self.uid = 1
|
self.uid = 1
|
||||||
if report is None:
|
if report is None:
|
||||||
report = assertion_report.assertion_report()
|
report = assertion_report.assertion_report()
|
||||||
|
@ -889,8 +887,6 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
|
||||||
#remove folder path from model
|
#remove folder path from model
|
||||||
head, model = os.path.split(model)
|
head, model = os.path.split(model)
|
||||||
|
|
||||||
pool = pooler.get_pool(cr.dbname)
|
|
||||||
|
|
||||||
input = cStringIO.StringIO(csvcontent) #FIXME
|
input = cStringIO.StringIO(csvcontent) #FIXME
|
||||||
reader = csv.reader(input, quotechar='"', delimiter=',')
|
reader = csv.reader(input, quotechar='"', delimiter=',')
|
||||||
fields = reader.next()
|
fields = reader.next()
|
||||||
|
@ -921,7 +917,9 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
|
||||||
datas.append(map(lambda x: misc.ustr(x), line))
|
datas.append(map(lambda x: misc.ustr(x), line))
|
||||||
except:
|
except:
|
||||||
_logger.error("Cannot import the line: %s", line)
|
_logger.error("Cannot import the line: %s", line)
|
||||||
result, rows, warning_msg, dummy = pool.get(model).import_data(cr, uid, fields, datas,mode, module, noupdate, filename=fname_partial)
|
|
||||||
|
registry = openerp.registry(cr.dbname)
|
||||||
|
result, rows, warning_msg, dummy = registry[model].import_data(cr, uid, fields, datas,mode, module, noupdate, filename=fname_partial)
|
||||||
if result < 0:
|
if result < 0:
|
||||||
# Report failed import and abort module install
|
# Report failed import and abort module install
|
||||||
raise Exception(_('Module loading failed: file %s/%s could not be processed:\n %s') % (module, fname, warning_msg))
|
raise Exception(_('Module loading failed: file %s/%s could not be processed:\n %s') % (module, fname, warning_msg))
|
||||||
|
|
|
@ -24,13 +24,13 @@ import cgi
|
||||||
import logging
|
import logging
|
||||||
import lxml.html
|
import lxml.html
|
||||||
import lxml.html.clean as clean
|
import lxml.html.clean as clean
|
||||||
import openerp.pooler as pooler
|
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import openerp
|
||||||
from openerp.loglevels import ustr
|
from openerp.loglevels import ustr
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
@ -325,13 +325,13 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
|
||||||
if not cr:
|
if not cr:
|
||||||
db_name = getattr(threading.currentThread(), 'dbname', None)
|
db_name = getattr(threading.currentThread(), 'dbname', None)
|
||||||
if db_name:
|
if db_name:
|
||||||
local_cr = cr = pooler.get_db(db_name).cursor()
|
local_cr = cr = openerp.registry(db_name).db.cursor()
|
||||||
else:
|
else:
|
||||||
raise Exception("No database cursor found, please pass one explicitly")
|
raise Exception("No database cursor found, please pass one explicitly")
|
||||||
|
|
||||||
# Send Email
|
# Send Email
|
||||||
try:
|
try:
|
||||||
mail_server_pool = pooler.get_pool(cr.dbname).get('ir.mail_server')
|
mail_server_pool = openerp.registry(cr.dbname)['ir.mail_server']
|
||||||
res = False
|
res = False
|
||||||
# Pack Message into MIME Object
|
# Pack Message into MIME Object
|
||||||
email_msg = mail_server_pool.build_email(email_from, email_to, subject, body, email_cc, email_bcc, reply_to,
|
email_msg = mail_server_pool.build_email(email_from, email_to, subject, body, email_cc, email_bcc, reply_to,
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
through the code of yaml tests.
|
through the code of yaml tests.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import openerp
|
||||||
import openerp.netsvc as netsvc
|
import openerp.netsvc as netsvc
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
import logging
|
import logging
|
||||||
import openerp.pooler as pooler
|
|
||||||
from openerp.tools.safe_eval import safe_eval
|
from openerp.tools.safe_eval import safe_eval
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import os
|
import os
|
||||||
|
@ -123,7 +123,7 @@ def try_report_action(cr, uid, action_id, active_model=None, active_ids=None,
|
||||||
context = context.copy() # keep it local
|
context = context.copy() # keep it local
|
||||||
# TODO context fill-up
|
# TODO context fill-up
|
||||||
|
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
|
|
||||||
def log_test(msg, *args):
|
def log_test(msg, *args):
|
||||||
_logger.log(netsvc.logging.TEST, " - " + msg, *args)
|
_logger.log(netsvc.logging.TEST, " - " + msg, *args)
|
||||||
|
@ -145,7 +145,7 @@ def try_report_action(cr, uid, action_id, active_model=None, active_ids=None,
|
||||||
raise ValueError('You cannot only specify action_id "%s" without a module name' % action_id)
|
raise ValueError('You cannot only specify action_id "%s" without a module name' % action_id)
|
||||||
act_module = our_module
|
act_module = our_module
|
||||||
act_xmlid = action_id
|
act_xmlid = action_id
|
||||||
act_model, act_id = pool.get('ir.model.data').get_object_reference(cr, uid, act_module, act_xmlid)
|
act_model, act_id = registry['ir.model.data'].get_object_reference(cr, uid, act_module, act_xmlid)
|
||||||
else:
|
else:
|
||||||
assert isinstance(action_id, (long, int))
|
assert isinstance(action_id, (long, int))
|
||||||
act_model = 'ir.action.act_window' # assume that
|
act_model = 'ir.action.act_window' # assume that
|
||||||
|
@ -181,11 +181,11 @@ def try_report_action(cr, uid, action_id, active_model=None, active_ids=None,
|
||||||
log_test("will emulate a %s view: %s#%s",
|
log_test("will emulate a %s view: %s#%s",
|
||||||
action['view_type'], datas['res_model'], view_id or '?')
|
action['view_type'], datas['res_model'], view_id or '?')
|
||||||
|
|
||||||
view_res = pool.get(datas['res_model']).fields_view_get(cr, uid, view_id, action['view_type'], context)
|
view_res = registry[datas['res_model']].fields_view_get(cr, uid, view_id, action['view_type'], context)
|
||||||
assert view_res and view_res.get('arch'), "Did not return any arch for the view"
|
assert view_res and view_res.get('arch'), "Did not return any arch for the view"
|
||||||
view_data = {}
|
view_data = {}
|
||||||
if view_res.get('fields',{}).keys():
|
if view_res.get('fields',{}).keys():
|
||||||
view_data = pool.get(datas['res_model']).default_get(cr, uid, view_res['fields'].keys(), context)
|
view_data = registry[datas['res_model']].default_get(cr, uid, view_res['fields'].keys(), context)
|
||||||
if datas.get('form'):
|
if datas.get('form'):
|
||||||
view_data.update(datas.get('form'))
|
view_data.update(datas.get('form'))
|
||||||
if wiz_data:
|
if wiz_data:
|
||||||
|
@ -238,7 +238,7 @@ def try_report_action(cr, uid, action_id, active_model=None, active_ids=None,
|
||||||
if not datas['res_id']:
|
if not datas['res_id']:
|
||||||
# it is probably an orm_memory object, we need to create
|
# it is probably an orm_memory object, we need to create
|
||||||
# an instance
|
# an instance
|
||||||
datas['res_id'] = pool.get(datas['res_model']).create(cr, uid, view_data, context)
|
datas['res_id'] = registry[datas['res_model']].create(cr, uid, view_data, context)
|
||||||
|
|
||||||
if not buttons:
|
if not buttons:
|
||||||
raise AssertionError("view form doesn't have any buttons to press!")
|
raise AssertionError("view form doesn't have any buttons to press!")
|
||||||
|
@ -255,7 +255,7 @@ def try_report_action(cr, uid, action_id, active_model=None, active_ids=None,
|
||||||
continue
|
continue
|
||||||
if b['type'] == 'object':
|
if b['type'] == 'object':
|
||||||
#there we are! press the button!
|
#there we are! press the button!
|
||||||
fn = getattr(pool.get(datas['res_model']), b['name'])
|
fn = getattr(registry[datas['res_model']], b['name'])
|
||||||
if not fn:
|
if not fn:
|
||||||
_logger.error("The %s model doesn't have a %s attribute!", datas['res_model'], b['name'])
|
_logger.error("The %s model doesn't have a %s attribute!", datas['res_model'], b['name'])
|
||||||
continue
|
continue
|
||||||
|
@ -281,7 +281,7 @@ def try_report_action(cr, uid, action_id, active_model=None, active_ids=None,
|
||||||
raise Exception("Cannot handle action of type %s" % act_model)
|
raise Exception("Cannot handle action of type %s" % act_model)
|
||||||
|
|
||||||
log_test("will be using %s action %s #%d", act_model, act_xmlid, act_id)
|
log_test("will be using %s action %s #%d", act_model, act_xmlid, act_id)
|
||||||
action = pool.get(act_model).read(cr, uid, act_id, context=context)
|
action = registry[act_model].read(cr, uid, act_id, context=context)
|
||||||
assert action, "Could not read action %s[%s]" %(act_model, act_id)
|
assert action, "Could not read action %s[%s]" %(act_model, act_id)
|
||||||
loop = 0
|
loop = 0
|
||||||
while action:
|
while action:
|
||||||
|
|
|
@ -25,7 +25,6 @@ import fnmatch
|
||||||
import inspect
|
import inspect
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
import openerp.pooler as pooler
|
|
||||||
import openerp.sql_db as sql_db
|
import openerp.sql_db as sql_db
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
@ -43,6 +42,7 @@ import misc
|
||||||
from misc import UpdateableStr
|
from misc import UpdateableStr
|
||||||
from misc import SKIPPED_ELEMENT_TYPES
|
from misc import SKIPPED_ELEMENT_TYPES
|
||||||
import osutil
|
import osutil
|
||||||
|
import openerp
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
@ -208,7 +208,7 @@ class GettextAlias(object):
|
||||||
(cr, dummy) = self._get_cr(frame, allow_create=False)
|
(cr, dummy) = self._get_cr(frame, allow_create=False)
|
||||||
uid = self._get_uid(frame)
|
uid = self._get_uid(frame)
|
||||||
if pool and cr and uid:
|
if pool and cr and uid:
|
||||||
lang = pool.get('res.users').context_get(cr, uid)['lang']
|
lang = pool['res.users'].context_get(cr, uid)['lang']
|
||||||
return lang
|
return lang
|
||||||
|
|
||||||
def __call__(self, source):
|
def __call__(self, source):
|
||||||
|
@ -227,8 +227,8 @@ class GettextAlias(object):
|
||||||
cr, is_new_cr = self._get_cr(frame)
|
cr, is_new_cr = self._get_cr(frame)
|
||||||
if cr:
|
if cr:
|
||||||
# Try to use ir.translation to benefit from global cache if possible
|
# Try to use ir.translation to benefit from global cache if possible
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
res = pool.get('ir.translation')._get_source(cr, SUPERUSER_ID, None, ('code','sql_constraint'), lang, source)
|
res = registry['ir.translation']._get_source(cr, SUPERUSER_ID, None, ('code','sql_constraint'), lang, source)
|
||||||
else:
|
else:
|
||||||
_logger.debug('no context cursor detected, skipping translation for "%r"', source)
|
_logger.debug('no context cursor detected, skipping translation for "%r"', source)
|
||||||
else:
|
else:
|
||||||
|
@ -611,11 +611,11 @@ def babel_extract_qweb(fileobj, keywords, comment_tags, options):
|
||||||
def trans_generate(lang, modules, cr):
|
def trans_generate(lang, modules, cr):
|
||||||
dbname = cr.dbname
|
dbname = cr.dbname
|
||||||
|
|
||||||
pool = pooler.get_pool(dbname)
|
registry = openerp.registry(dbname)
|
||||||
trans_obj = pool.get('ir.translation')
|
trans_obj = registry.get('ir.translation')
|
||||||
model_data_obj = pool.get('ir.model.data')
|
model_data_obj = registry.get('ir.model.data')
|
||||||
uid = 1
|
uid = 1
|
||||||
l = pool.models.items()
|
l = registry.models.items()
|
||||||
l.sort()
|
l.sort()
|
||||||
|
|
||||||
query = 'SELECT name, model, res_id, module' \
|
query = 'SELECT name, model, res_id, module' \
|
||||||
|
@ -659,15 +659,15 @@ def trans_generate(lang, modules, cr):
|
||||||
model = encode(model)
|
model = encode(model)
|
||||||
xml_name = "%s.%s" % (module, encode(xml_name))
|
xml_name = "%s.%s" % (module, encode(xml_name))
|
||||||
|
|
||||||
if not pool.get(model):
|
if not registry.get(model):
|
||||||
_logger.error("Unable to find object %r", model)
|
_logger.error("Unable to find object %r", model)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
exists = pool.get(model).exists(cr, uid, res_id)
|
exists = registry[model].exists(cr, uid, res_id)
|
||||||
if not exists:
|
if not exists:
|
||||||
_logger.warning("Unable to find object %r with id %d", model, res_id)
|
_logger.warning("Unable to find object %r with id %d", model, res_id)
|
||||||
continue
|
continue
|
||||||
obj = pool.get(model).browse(cr, uid, res_id)
|
obj = registry[model].browse(cr, uid, res_id)
|
||||||
|
|
||||||
if model=='ir.ui.view':
|
if model=='ir.ui.view':
|
||||||
d = etree.XML(encode(obj.arch))
|
d = etree.XML(encode(obj.arch))
|
||||||
|
@ -682,7 +682,7 @@ def trans_generate(lang, modules, cr):
|
||||||
except AttributeError, exc:
|
except AttributeError, exc:
|
||||||
_logger.error("name error in %s: %s", xml_name, str(exc))
|
_logger.error("name error in %s: %s", xml_name, str(exc))
|
||||||
continue
|
continue
|
||||||
objmodel = pool.get(obj.model)
|
objmodel = registry[obj.model]
|
||||||
if not objmodel or not field_name in objmodel._columns:
|
if not objmodel or not field_name in objmodel._columns:
|
||||||
continue
|
continue
|
||||||
field_def = objmodel._columns[field_name]
|
field_def = objmodel._columns[field_name]
|
||||||
|
@ -764,7 +764,7 @@ def trans_generate(lang, modules, cr):
|
||||||
push_constraint_msg(module, term_type, model._name, constraint[msg_pos])
|
push_constraint_msg(module, term_type, model._name, constraint[msg_pos])
|
||||||
|
|
||||||
for (_, model, module) in cr.fetchall():
|
for (_, model, module) in cr.fetchall():
|
||||||
model_obj = pool.get(model)
|
model_obj = registry.get(model)
|
||||||
|
|
||||||
if not model_obj:
|
if not model_obj:
|
||||||
_logger.error("Unable to find object %r", model)
|
_logger.error("Unable to find object %r", model)
|
||||||
|
@ -794,7 +794,7 @@ def trans_generate(lang, modules, cr):
|
||||||
return path.split(os.path.sep)[0]
|
return path.split(os.path.sep)[0]
|
||||||
return 'base' # files that are not in a module are considered as being in 'base' module
|
return 'base' # files that are not in a module are considered as being in 'base' module
|
||||||
|
|
||||||
modobj = pool.get('ir.module.module')
|
modobj = registry['ir.module.module']
|
||||||
installed_modids = modobj.search(cr, uid, [('state', '=', 'installed')])
|
installed_modids = modobj.search(cr, uid, [('state', '=', 'installed')])
|
||||||
installed_modules = map(lambda m: m['name'], modobj.read(cr, uid, installed_modids, ['name']))
|
installed_modules = map(lambda m: m['name'], modobj.read(cr, uid, installed_modids, ['name']))
|
||||||
|
|
||||||
|
@ -887,9 +887,9 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True,
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
db_name = cr.dbname
|
db_name = cr.dbname
|
||||||
pool = pooler.get_pool(db_name)
|
registry = openerp.registry(db_name)
|
||||||
lang_obj = pool.get('res.lang')
|
lang_obj = registry.get('res.lang')
|
||||||
trans_obj = pool.get('ir.translation')
|
trans_obj = registry.get('ir.translation')
|
||||||
iso_lang = misc.get_iso_codes(lang)
|
iso_lang = misc.get_iso_codes(lang)
|
||||||
try:
|
try:
|
||||||
ids = lang_obj.search(cr, SUPERUSER_ID, [('code','=', lang)])
|
ids = lang_obj.search(cr, SUPERUSER_ID, [('code','=', lang)])
|
||||||
|
@ -1009,11 +1009,10 @@ def load_language(cr, lang):
|
||||||
:param lang: language ISO code with optional _underscore_ and l10n flavor (ex: 'fr', 'fr_BE', but not 'fr-BE')
|
:param lang: language ISO code with optional _underscore_ and l10n flavor (ex: 'fr', 'fr_BE', but not 'fr-BE')
|
||||||
:type lang: str
|
:type lang: str
|
||||||
"""
|
"""
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
language_installer = pool.get('base.language.install')
|
language_installer = registry['base.language.install']
|
||||||
uid = 1
|
oid = language_installer.create(cr, SUPERUSER_ID, {'lang': lang})
|
||||||
oid = language_installer.create(cr, uid, {'lang': lang})
|
language_installer.lang_install(cr, SUPERUSER_ID, [oid], context=None)
|
||||||
language_installer.lang_install(cr, uid, [oid], context=None)
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import time # used to eval time.strftime expressions
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import openerp.pooler as pooler
|
import openerp
|
||||||
import openerp.sql_db as sql_db
|
import openerp.sql_db as sql_db
|
||||||
import misc
|
import misc
|
||||||
from config import config
|
from config import config
|
||||||
|
@ -112,7 +112,7 @@ class YamlInterpreter(object):
|
||||||
self.assertion_report = report
|
self.assertion_report = report
|
||||||
self.noupdate = noupdate
|
self.noupdate = noupdate
|
||||||
self.loglevel = loglevel
|
self.loglevel = loglevel
|
||||||
self.pool = pooler.get_pool(cr.dbname)
|
self.pool = openerp.registry(cr.dbname)
|
||||||
self.uid = 1
|
self.uid = 1
|
||||||
self.context = {} # opererp context
|
self.context = {} # opererp context
|
||||||
self.eval_context = {'ref': self._ref(),
|
self.eval_context = {'ref': self._ref(),
|
||||||
|
@ -128,9 +128,7 @@ class YamlInterpreter(object):
|
||||||
return lambda xml_id: self.get_id(xml_id)
|
return lambda xml_id: self.get_id(xml_id)
|
||||||
|
|
||||||
def get_model(self, model_name):
|
def get_model(self, model_name):
|
||||||
model = self.pool.get(model_name)
|
return self.pool[model_name]
|
||||||
assert model, "The model %s does not exist." % (model_name,)
|
|
||||||
return model
|
|
||||||
|
|
||||||
def validate_xml_id(self, xml_id):
|
def validate_xml_id(self, xml_id):
|
||||||
id = xml_id
|
id = xml_id
|
||||||
|
@ -140,7 +138,7 @@ class YamlInterpreter(object):
|
||||||
"It is used to refer to other modules ID, in the form: module.record_id" \
|
"It is used to refer to other modules ID, in the form: module.record_id" \
|
||||||
% (xml_id,)
|
% (xml_id,)
|
||||||
if module != self.module:
|
if module != self.module:
|
||||||
module_count = self.pool.get('ir.module.module').search_count(self.cr, self.uid, \
|
module_count = self.pool['ir.module.module'].search_count(self.cr, self.uid, \
|
||||||
['&', ('name', '=', module), ('state', 'in', ['installed'])])
|
['&', ('name', '=', module), ('state', 'in', ['installed'])])
|
||||||
assert module_count == 1, 'The ID "%s" refers to an uninstalled module.' % (xml_id,)
|
assert module_count == 1, 'The ID "%s" refers to an uninstalled module.' % (xml_id,)
|
||||||
if len(id) > 64: # TODO where does 64 come from (DB is 128)? should be a constant or loaded form DB
|
if len(id) > 64: # TODO where does 64 come from (DB is 128)? should be a constant or loaded form DB
|
||||||
|
@ -162,7 +160,7 @@ class YamlInterpreter(object):
|
||||||
module = self.module
|
module = self.module
|
||||||
checked_xml_id = xml_id
|
checked_xml_id = xml_id
|
||||||
try:
|
try:
|
||||||
_, id = self.pool.get('ir.model.data').get_object_reference(self.cr, self.uid, module, checked_xml_id)
|
_, id = self.pool['ir.model.data'].get_object_reference(self.cr, self.uid, module, checked_xml_id)
|
||||||
self.id_map[xml_id] = id
|
self.id_map[xml_id] = id
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValueError("""%s not found when processing %s.
|
raise ValueError("""%s not found when processing %s.
|
||||||
|
@ -201,7 +199,7 @@ class YamlInterpreter(object):
|
||||||
ids = [self.get_id(assertion.id)]
|
ids = [self.get_id(assertion.id)]
|
||||||
elif assertion.search:
|
elif assertion.search:
|
||||||
q = eval(assertion.search, self.eval_context)
|
q = eval(assertion.search, self.eval_context)
|
||||||
ids = self.pool.get(assertion.model).search(self.cr, self.uid, q, context=assertion.context)
|
ids = self.pool[assertion.model].search(self.cr, self.uid, q, context=assertion.context)
|
||||||
else:
|
else:
|
||||||
raise YamlImportException('Nothing to assert: you must give either an id or a search criteria.')
|
raise YamlImportException('Nothing to assert: you must give either an id or a search criteria.')
|
||||||
return ids
|
return ids
|
||||||
|
@ -290,20 +288,20 @@ class YamlInterpreter(object):
|
||||||
module = self.module
|
module = self.module
|
||||||
if '.' in view_id:
|
if '.' in view_id:
|
||||||
module, view_id = view_id.split('.',1)
|
module, view_id = view_id.split('.',1)
|
||||||
view_id = self.pool.get('ir.model.data').get_object_reference(self.cr, SUPERUSER_ID, module, view_id)[1]
|
view_id = self.pool['ir.model.data'].get_object_reference(self.cr, SUPERUSER_ID, module, view_id)[1]
|
||||||
|
|
||||||
if model.is_transient():
|
if model.is_transient():
|
||||||
record_dict=self.create_osv_memory_record(record, fields)
|
record_dict=self.create_osv_memory_record(record, fields)
|
||||||
else:
|
else:
|
||||||
self.validate_xml_id(record.id)
|
self.validate_xml_id(record.id)
|
||||||
try:
|
try:
|
||||||
self.pool.get('ir.model.data')._get_id(self.cr, SUPERUSER_ID, self.module, record.id)
|
self.pool['ir.model.data']._get_id(self.cr, SUPERUSER_ID, self.module, record.id)
|
||||||
default = False
|
default = False
|
||||||
except ValueError:
|
except ValueError:
|
||||||
default = True
|
default = True
|
||||||
|
|
||||||
if self.isnoupdate(record) and self.mode != 'init':
|
if self.isnoupdate(record) and self.mode != 'init':
|
||||||
id = self.pool.get('ir.model.data')._update_dummy(self.cr, SUPERUSER_ID, record.model, self.module, record.id)
|
id = self.pool['ir.model.data']._update_dummy(self.cr, SUPERUSER_ID, record.model, self.module, record.id)
|
||||||
# check if the resource already existed at the last update
|
# check if the resource already existed at the last update
|
||||||
if id:
|
if id:
|
||||||
self.id_map[record] = int(id)
|
self.id_map[record] = int(id)
|
||||||
|
@ -324,7 +322,7 @@ class YamlInterpreter(object):
|
||||||
|
|
||||||
record_dict = self._create_record(model, fields, view_info, default=default)
|
record_dict = self._create_record(model, fields, view_info, default=default)
|
||||||
_logger.debug("RECORD_DICT %s" % record_dict)
|
_logger.debug("RECORD_DICT %s" % record_dict)
|
||||||
id = self.pool.get('ir.model.data')._update(self.cr, SUPERUSER_ID, record.model, \
|
id = self.pool['ir.model.data']._update(self.cr, SUPERUSER_ID, record.model, \
|
||||||
self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode, context=context)
|
self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode, context=context)
|
||||||
self.id_map[record.id] = int(id)
|
self.id_map[record.id] = int(id)
|
||||||
if config.get('import_partial'):
|
if config.get('import_partial'):
|
||||||
|
@ -346,7 +344,7 @@ class YamlInterpreter(object):
|
||||||
one2many_view = fg[field_name]['views'].get(view_type)
|
one2many_view = fg[field_name]['views'].get(view_type)
|
||||||
# if the view is not defined inline, we call fields_view_get()
|
# if the view is not defined inline, we call fields_view_get()
|
||||||
if not one2many_view:
|
if not one2many_view:
|
||||||
one2many_view = self.pool.get(fg[field_name]['relation']).fields_view_get(self.cr, SUPERUSER_ID, False, view_type, self.context)
|
one2many_view = self.pool[fg[field_name]['relation']].fields_view_get(self.cr, SUPERUSER_ID, False, view_type, self.context)
|
||||||
return one2many_view
|
return one2many_view
|
||||||
|
|
||||||
def process_val(key, val):
|
def process_val(key, val):
|
||||||
|
@ -707,7 +705,7 @@ class YamlInterpreter(object):
|
||||||
|
|
||||||
self._set_group_values(node, values)
|
self._set_group_values(node, values)
|
||||||
|
|
||||||
pid = self.pool.get('ir.model.data')._update(self.cr, SUPERUSER_ID, \
|
pid = self.pool['ir.model.data']._update(self.cr, SUPERUSER_ID, \
|
||||||
'ir.ui.menu', self.module, values, node.id, mode=self.mode, \
|
'ir.ui.menu', self.module, values, node.id, mode=self.mode, \
|
||||||
noupdate=self.isnoupdate(node), res_id=res and res[0] or False)
|
noupdate=self.isnoupdate(node), res_id=res and res[0] or False)
|
||||||
|
|
||||||
|
@ -718,7 +716,7 @@ class YamlInterpreter(object):
|
||||||
action_type = node.type or 'act_window'
|
action_type = node.type or 'act_window'
|
||||||
action_id = self.get_id(node.action)
|
action_id = self.get_id(node.action)
|
||||||
action = "ir.actions.%s,%d" % (action_type, action_id)
|
action = "ir.actions.%s,%d" % (action_type, action_id)
|
||||||
self.pool.get('ir.model.data').ir_set(self.cr, SUPERUSER_ID, 'action', \
|
self.pool['ir.model.data'].ir_set(self.cr, SUPERUSER_ID, 'action', \
|
||||||
'tree_but_open', 'Menuitem', [('ir.ui.menu', int(parent_id))], action, True, True, xml_id=node.id)
|
'tree_but_open', 'Menuitem', [('ir.ui.menu', int(parent_id))], action, True, True, xml_id=node.id)
|
||||||
|
|
||||||
def process_act_window(self, node):
|
def process_act_window(self, node):
|
||||||
|
@ -752,7 +750,7 @@ class YamlInterpreter(object):
|
||||||
|
|
||||||
if node.target:
|
if node.target:
|
||||||
values['target'] = node.target
|
values['target'] = node.target
|
||||||
id = self.pool.get('ir.model.data')._update(self.cr, SUPERUSER_ID, \
|
id = self.pool['ir.model.data']._update(self.cr, SUPERUSER_ID, \
|
||||||
'ir.actions.act_window', self.module, values, node.id, mode=self.mode)
|
'ir.actions.act_window', self.module, values, node.id, mode=self.mode)
|
||||||
self.id_map[node.id] = int(id)
|
self.id_map[node.id] = int(id)
|
||||||
|
|
||||||
|
@ -760,7 +758,7 @@ class YamlInterpreter(object):
|
||||||
keyword = 'client_action_relate'
|
keyword = 'client_action_relate'
|
||||||
value = 'ir.actions.act_window,%s' % id
|
value = 'ir.actions.act_window,%s' % id
|
||||||
replace = node.replace or True
|
replace = node.replace or True
|
||||||
self.pool.get('ir.model.data').ir_set(self.cr, SUPERUSER_ID, 'action', keyword, \
|
self.pool['ir.model.data'].ir_set(self.cr, SUPERUSER_ID, 'action', keyword, \
|
||||||
node.id, [node.src_model], value, replace=replace, noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
|
node.id, [node.src_model], value, replace=replace, noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
|
||||||
# TODO add remove ir.model.data
|
# TODO add remove ir.model.data
|
||||||
|
|
||||||
|
@ -768,11 +766,11 @@ class YamlInterpreter(object):
|
||||||
assert getattr(node, 'model'), "Attribute %s of delete tag is empty !" % ('model',)
|
assert getattr(node, 'model'), "Attribute %s of delete tag is empty !" % ('model',)
|
||||||
if self.pool.get(node.model):
|
if self.pool.get(node.model):
|
||||||
if node.search:
|
if node.search:
|
||||||
ids = self.pool.get(node.model).search(self.cr, self.uid, eval(node.search, self.eval_context))
|
ids = self.pool[node.model].search(self.cr, self.uid, eval(node.search, self.eval_context))
|
||||||
else:
|
else:
|
||||||
ids = [self.get_id(node.id)]
|
ids = [self.get_id(node.id)]
|
||||||
if len(ids):
|
if len(ids):
|
||||||
self.pool.get(node.model).unlink(self.cr, self.uid, ids)
|
self.pool[node.model].unlink(self.cr, self.uid, ids)
|
||||||
else:
|
else:
|
||||||
self._log("Record not deleted.")
|
self._log("Record not deleted.")
|
||||||
|
|
||||||
|
@ -781,7 +779,7 @@ class YamlInterpreter(object):
|
||||||
|
|
||||||
res = {'name': node.name, 'url': node.url, 'target': node.target}
|
res = {'name': node.name, 'url': node.url, 'target': node.target}
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(self.cr, SUPERUSER_ID, \
|
id = self.pool['ir.model.data']._update(self.cr, SUPERUSER_ID, \
|
||||||
"ir.actions.act_url", self.module, res, node.id, mode=self.mode)
|
"ir.actions.act_url", self.module, res, node.id, mode=self.mode)
|
||||||
self.id_map[node.id] = int(id)
|
self.id_map[node.id] = int(id)
|
||||||
# ir_set
|
# ir_set
|
||||||
|
@ -789,7 +787,7 @@ class YamlInterpreter(object):
|
||||||
keyword = node.keyword or 'client_action_multi'
|
keyword = node.keyword or 'client_action_multi'
|
||||||
value = 'ir.actions.act_url,%s' % id
|
value = 'ir.actions.act_url,%s' % id
|
||||||
replace = node.replace or True
|
replace = node.replace or True
|
||||||
self.pool.get('ir.model.data').ir_set(self.cr, SUPERUSER_ID, 'action', \
|
self.pool['ir.model.data'].ir_set(self.cr, SUPERUSER_ID, 'action', \
|
||||||
keyword, node.url, ["ir.actions.act_url"], value, replace=replace, \
|
keyword, node.url, ["ir.actions.act_url"], value, replace=replace, \
|
||||||
noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
|
noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
|
||||||
|
|
||||||
|
@ -804,7 +802,7 @@ class YamlInterpreter(object):
|
||||||
else:
|
else:
|
||||||
value = expression
|
value = expression
|
||||||
res[fieldname] = value
|
res[fieldname] = value
|
||||||
self.pool.get('ir.model.data').ir_set(self.cr, SUPERUSER_ID, res['key'], res['key2'], \
|
self.pool['ir.model.data'].ir_set(self.cr, SUPERUSER_ID, res['key'], res['key2'], \
|
||||||
res['name'], res['models'], res['value'], replace=res.get('replace',True), \
|
res['name'], res['models'], res['value'], replace=res.get('replace',True), \
|
||||||
isobject=res.get('isobject', False), meta=res.get('meta',None))
|
isobject=res.get('isobject', False), meta=res.get('meta',None))
|
||||||
|
|
||||||
|
@ -833,7 +831,7 @@ class YamlInterpreter(object):
|
||||||
|
|
||||||
self._set_group_values(node, values)
|
self._set_group_values(node, values)
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(self.cr, SUPERUSER_ID, "ir.actions.report.xml", \
|
id = self.pool['ir.model.data']._update(self.cr, SUPERUSER_ID, "ir.actions.report.xml", \
|
||||||
self.module, values, xml_id, noupdate=self.isnoupdate(node), mode=self.mode)
|
self.module, values, xml_id, noupdate=self.isnoupdate(node), mode=self.mode)
|
||||||
self.id_map[xml_id] = int(id)
|
self.id_map[xml_id] = int(id)
|
||||||
|
|
||||||
|
@ -841,7 +839,7 @@ class YamlInterpreter(object):
|
||||||
keyword = node.keyword or 'client_print_multi'
|
keyword = node.keyword or 'client_print_multi'
|
||||||
value = 'ir.actions.report.xml,%s' % id
|
value = 'ir.actions.report.xml,%s' % id
|
||||||
replace = node.replace or True
|
replace = node.replace or True
|
||||||
self.pool.get('ir.model.data').ir_set(self.cr, SUPERUSER_ID, 'action', \
|
self.pool['ir.model.data'].ir_set(self.cr, SUPERUSER_ID, 'action', \
|
||||||
keyword, values['name'], [values['model']], value, replace=replace, isobject=True, xml_id=xml_id)
|
keyword, values['name'], [values['model']], value, replace=replace, isobject=True, xml_id=xml_id)
|
||||||
|
|
||||||
def process_none(self):
|
def process_none(self):
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import openerp.pooler as pooler
|
import openerp
|
||||||
from openerp.tools.safe_eval import safe_eval as eval
|
from openerp.tools.safe_eval import safe_eval as eval
|
||||||
|
|
||||||
class Env(dict):
|
class Env(dict):
|
||||||
|
@ -28,7 +28,7 @@ class Env(dict):
|
||||||
self.uid = uid
|
self.uid = uid
|
||||||
self.model = model
|
self.model = model
|
||||||
self.ids = ids
|
self.ids = ids
|
||||||
self.obj = pooler.get_pool(cr.dbname).get(model)
|
self.obj = openerp.registry(cr.dbname)[model]
|
||||||
self.columns = self.obj._columns.keys() + self.obj._inherit_fields.keys()
|
self.columns = self.obj._columns.keys() + self.obj._inherit_fields.keys()
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
@ -58,7 +58,7 @@ def _eval_expr(cr, ident, workitem, action):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def execute_action(cr, ident, workitem, activity):
|
def execute_action(cr, ident, workitem, activity):
|
||||||
obj = pooler.get_pool(cr.dbname).get('ir.actions.server')
|
obj = openerp.registry(cr.dbname)['ir.actions.server']
|
||||||
ctx = {'active_model':ident[1], 'active_id':ident[2], 'active_ids':[ident[2]]}
|
ctx = {'active_model':ident[1], 'active_id':ident[2], 'active_ids':[ident[2]]}
|
||||||
result = obj.run(cr, ident[0], [activity['action_id']], ctx)
|
result = obj.run(cr, ident[0], [activity['action_id']], ctx)
|
||||||
return result
|
return result
|
||||||
|
@ -72,8 +72,8 @@ def check(cr, workitem, ident, transition, signal):
|
||||||
|
|
||||||
uid = ident[0]
|
uid = ident[0]
|
||||||
if transition['group_id'] and uid != 1:
|
if transition['group_id'] and uid != 1:
|
||||||
pool = pooler.get_pool(cr.dbname)
|
registry = openerp.registry(cr.dbname)
|
||||||
user_groups = pool.get('res.users').read(cr, uid, [uid], ['groups_id'])[0]['groups_id']
|
user_groups = registry['res.users'].read(cr, uid, [uid], ['groups_id'])[0]['groups_id']
|
||||||
if not transition['group_id'] in user_groups:
|
if not transition['group_id'] in user_groups:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue