[REF] Replace the user id 1 by openerp.SUPERUSER_ID
bzr revid: stw@openerp.com-20120831135309-o4plzf5wp0kyuzgf
This commit is contained in:
parent
1eac0fbe52
commit
b3988436cb
|
@ -35,6 +35,7 @@ from tools.config import config
|
||||||
from tools.safe_eval import safe_eval as eval
|
from tools.safe_eval import safe_eval as eval
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
from socket import gethostname
|
from socket import gethostname
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -271,7 +272,7 @@ class act_window(osv.osv):
|
||||||
:return: A read() view of the ir.actions.act_window
|
:return: A read() view of the ir.actions.act_window
|
||||||
"""
|
"""
|
||||||
dataobj = self.pool.get('ir.model.data')
|
dataobj = self.pool.get('ir.model.data')
|
||||||
data_id = dataobj._get_id (cr, 1, module, xml_id)
|
data_id = dataobj._get_id (cr, SUPERUSER_ID, module, xml_id)
|
||||||
res_id = dataobj.browse(cr, uid, data_id, context).res_id
|
res_id = dataobj.browse(cr, uid, data_id, context).res_id
|
||||||
return self.read(cr, uid, res_id, [], context)
|
return self.read(cr, uid, res_id, [], context)
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ from osv import osv,fields
|
||||||
import uuid
|
import uuid
|
||||||
import datetime
|
import datetime
|
||||||
from tools import misc, config
|
from tools import misc, config
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
"""
|
"""
|
||||||
A dictionary holding some configuration parameters to be initialized when the database is created.
|
A dictionary holding some configuration parameters to be initialized when the database is created.
|
||||||
|
@ -55,9 +56,9 @@ class ir_config_parameter(osv.osv):
|
||||||
Initializes the parameters listed in _default_parameters.
|
Initializes the parameters listed in _default_parameters.
|
||||||
"""
|
"""
|
||||||
for key, func in _default_parameters.iteritems():
|
for key, func in _default_parameters.iteritems():
|
||||||
ids = self.search(cr, 1, [('key','=',key)])
|
ids = self.search(cr, SUPERUSER_ID, [('key','=',key)])
|
||||||
if not ids:
|
if not ids:
|
||||||
self.set_param(cr, 1, key, func())
|
self.set_param(cr, SUPERUSER_ID, key, func())
|
||||||
|
|
||||||
def get_param(self, cr, uid, key, default=False, context=None):
|
def get_param(self, cr, uid, key, default=False, context=None):
|
||||||
"""Retrieve the value for a given key.
|
"""Retrieve the value for a given key.
|
||||||
|
|
|
@ -44,7 +44,7 @@ class ir_rule(osv.osv):
|
||||||
def _eval_context(self, cr, uid):
|
def _eval_context(self, cr, uid):
|
||||||
"""Returns a dictionary to use as evaluation context for
|
"""Returns a dictionary to use as evaluation context for
|
||||||
ir.rule domains."""
|
ir.rule domains."""
|
||||||
return {'user': self.pool.get('res.users').browse(cr, 1, uid),
|
return {'user': self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid),
|
||||||
'time':time}
|
'time':time}
|
||||||
|
|
||||||
def _domain_force_get(self, cr, uid, ids, field_name, arg, context=None):
|
def _domain_force_get(self, cr, uid, ids, field_name, arg, context=None):
|
||||||
|
@ -152,7 +152,7 @@ class ir_rule(osv.osv):
|
||||||
# involve objects on which the real uid has no acces rights.
|
# involve objects on which the real uid has no acces rights.
|
||||||
# This means also there is no implicit restriction (e.g. an object
|
# This means also there is no implicit restriction (e.g. an object
|
||||||
# references another object the user can't see).
|
# references another object the user can't see).
|
||||||
query = self.pool.get(model_name)._where_calc(cr, 1, dom, active_test=False)
|
query = self.pool.get(model_name)._where_calc(cr, SUPERUSER_ID, dom, active_test=False)
|
||||||
return query.where_clause, query.where_clause_params, query.tables
|
return query.where_clause, query.where_clause_params, query.tables
|
||||||
return [], [], ['"'+self.pool.get(model_name)._table+'"']
|
return [], [], ['"'+self.pool.get(model_name)._table+'"']
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import tools
|
||||||
import openerp.modules
|
import openerp.modules
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
def one_in(setA, setB):
|
def one_in(setA, setB):
|
||||||
"""Check the presence of an element of setA in setB
|
"""Check the presence of an element of setA in setB
|
||||||
|
@ -59,7 +60,7 @@ class ir_ui_menu(osv.osv):
|
||||||
"""
|
"""
|
||||||
with self.cache_lock:
|
with self.cache_lock:
|
||||||
modelaccess = self.pool.get('ir.model.access')
|
modelaccess = self.pool.get('ir.model.access')
|
||||||
user_groups = set(self.pool.get('res.users').read(cr, 1, uid, ['groups_id'])['groups_id'])
|
user_groups = set(self.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['groups_id'])['groups_id'])
|
||||||
result = []
|
result = []
|
||||||
for menu in self.browse(cr, uid, ids, context=context):
|
for menu in self.browse(cr, uid, ids, context=context):
|
||||||
# this key works because user access rights are all based on user's groups (cfr ir_model_access.check)
|
# this key works because user access rights are all based on user's groups (cfr ir_model_access.check)
|
||||||
|
|
|
@ -24,6 +24,7 @@ from osv import fields
|
||||||
import os
|
import os
|
||||||
import tools
|
import tools
|
||||||
import openerp
|
import openerp
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
from tools.safe_eval import safe_eval as eval
|
from tools.safe_eval import safe_eval as eval
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ class res_company(osv.osv):
|
||||||
# select only the currently visible companies (according to rules,
|
# select only the currently visible companies (according to rules,
|
||||||
# which are probably to allow to see the child companies) even if
|
# which are probably to allow to see the child companies) even if
|
||||||
# she belongs to some other companies.
|
# she belongs to some other companies.
|
||||||
user = self.pool.get('res.users').browse(cr, 1, uid, context=context)
|
user = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context)
|
||||||
cmp_ids = list(set([user.company_id.id] + [cmp.id for cmp in user.company_ids]))
|
cmp_ids = list(set([user.company_id.id] + [cmp.id for cmp in user.company_ids]))
|
||||||
return cmp_ids
|
return cmp_ids
|
||||||
return super(res_company, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
|
return super(res_company, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
|
||||||
|
|
|
@ -26,6 +26,7 @@ import logging
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from lxml.builder import E
|
from lxml.builder import E
|
||||||
import netsvc
|
import netsvc
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
import openerp
|
import openerp
|
||||||
import openerp.exceptions
|
import openerp.exceptions
|
||||||
from osv import fields,osv
|
from osv import fields,osv
|
||||||
|
@ -233,9 +234,9 @@ class res_users(osv.osv):
|
||||||
dataobj = self.pool.get('ir.model.data')
|
dataobj = self.pool.get('ir.model.data')
|
||||||
result = []
|
result = []
|
||||||
try:
|
try:
|
||||||
dummy,group_id = dataobj.get_object_reference(cr, 1, 'base', 'group_user')
|
dummy,group_id = dataobj.get_object_reference(cr, SUPERUSER_ID, 'base', 'group_user')
|
||||||
result.append(group_id)
|
result.append(group_id)
|
||||||
dummy,group_id = dataobj.get_object_reference(cr, 1, 'base', 'group_partner_manager')
|
dummy,group_id = dataobj.get_object_reference(cr, SUPERUSER_ID, 'base', 'group_partner_manager')
|
||||||
result.append(group_id)
|
result.append(group_id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# If these groups does not exists anymore
|
# If these groups does not exists anymore
|
||||||
|
@ -275,7 +276,7 @@ class res_users(osv.osv):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if 'company_id' in values:
|
if 'company_id' in values:
|
||||||
if not (values['company_id'] in self.read(cr, 1, uid, ['company_ids'], context=context)['company_ids']):
|
if not (values['company_id'] in self.read(cr, SUPERUSER_ID, uid, ['company_ids'], context=context)['company_ids']):
|
||||||
del values['company_id']
|
del values['company_id']
|
||||||
uid = 1 # safe fields only, so we write as super-user to bypass access rights
|
uid = 1 # safe fields only, so we write as super-user to bypass access rights
|
||||||
|
|
||||||
|
@ -327,7 +328,7 @@ class res_users(osv.osv):
|
||||||
return super(res_users, self).copy(cr, uid, id, copydef, context)
|
return super(res_users, self).copy(cr, uid, id, copydef, context)
|
||||||
|
|
||||||
def context_get(self, cr, uid, context=None):
|
def context_get(self, cr, uid, context=None):
|
||||||
user = self.browse(cr, 1, uid, context)
|
user = self.browse(cr, SUPERUSER_ID, uid, context)
|
||||||
result = {}
|
result = {}
|
||||||
for k in self._all_columns.keys():
|
for k in self._all_columns.keys():
|
||||||
if k.startswith('context_'):
|
if k.startswith('context_'):
|
||||||
|
@ -345,7 +346,7 @@ class res_users(osv.osv):
|
||||||
|
|
||||||
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.get('ir.model.data')
|
||||||
data_id = dataobj._get_id(cr, 1, '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
|
||||||
|
|
||||||
def check_super(self, passwd):
|
def check_super(self, passwd):
|
||||||
|
@ -356,7 +357,7 @@ class res_users(osv.osv):
|
||||||
|
|
||||||
def check_credentials(self, cr, uid, password):
|
def check_credentials(self, cr, uid, password):
|
||||||
""" Override this method to plug additional authentication methods"""
|
""" Override this method to plug additional authentication methods"""
|
||||||
res = self.search(cr, 1, [('id','=',uid),('password','=',password)])
|
res = self.search(cr, SUPERUSER_ID, [('id','=',uid),('password','=',password)])
|
||||||
if not res:
|
if not res:
|
||||||
raise openerp.exceptions.AccessDenied()
|
raise openerp.exceptions.AccessDenied()
|
||||||
|
|
||||||
|
@ -372,7 +373,7 @@ class res_users(osv.osv):
|
||||||
# of them rolled back due to a concurrent access.)
|
# of them rolled back due to a concurrent access.)
|
||||||
cr.autocommit(True)
|
cr.autocommit(True)
|
||||||
# check if user exists
|
# check if user exists
|
||||||
res = self.search(cr, 1, [('login','=',login)])
|
res = self.search(cr, SUPERUSER_ID, [('login','=',login)])
|
||||||
if res:
|
if res:
|
||||||
user_id = res[0]
|
user_id = res[0]
|
||||||
# check credentials
|
# check credentials
|
||||||
|
@ -537,7 +538,7 @@ class groups_implied(osv.osv):
|
||||||
return memo[g]
|
return memo[g]
|
||||||
|
|
||||||
res = {}
|
res = {}
|
||||||
for g in self.browse(cr, 1, ids, context):
|
for g in self.browse(cr, SUPERUSER_ID, ids, context):
|
||||||
res[g.id] = map(int, computed_set(g))
|
res[g.id] = map(int, computed_set(g))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -682,7 +683,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, 1, 'base', 'user_groups_view', context)
|
view = self.pool.get('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
|
||||||
|
|
|
@ -39,6 +39,7 @@ import openerp.pooler as pooler
|
||||||
import openerp.release as release
|
import openerp.release as release
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
import openerp.tools.assertion_report as assertion_report
|
import openerp.tools.assertion_report as assertion_report
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
@ -296,7 +297,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
||||||
modobj = pool.get('ir.module.module')
|
modobj = pool.get('ir.module.module')
|
||||||
if ('base' in tools.config['init']) or ('base' in tools.config['update']):
|
if ('base' in tools.config['init']) or ('base' in tools.config['update']):
|
||||||
_logger.info('updating modules list')
|
_logger.info('updating modules list')
|
||||||
modobj.update_list(cr, 1)
|
modobj.update_list(cr, SUPERUSER_ID)
|
||||||
|
|
||||||
_check_module_names(cr, itertools.chain(tools.config['init'].keys(), tools.config['update'].keys()))
|
_check_module_names(cr, itertools.chain(tools.config['init'].keys(), tools.config['update'].keys()))
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ from openerp.tools.translate import _
|
||||||
from openerp.tools import float_round, float_repr
|
from openerp.tools import float_round, float_repr
|
||||||
import simplejson
|
import simplejson
|
||||||
from openerp.tools.html_sanitize import html_sanitize
|
from openerp.tools.html_sanitize import html_sanitize
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -444,7 +445,7 @@ class many2one(_column):
|
||||||
# build a dictionary of the form {'id_of_distant_resource': name_of_distant_resource}
|
# build a dictionary of the form {'id_of_distant_resource': name_of_distant_resource}
|
||||||
# we use uid=1 because the visibility of a many2one field value (just id and name)
|
# we use uid=1 because the visibility of a many2one field value (just id and name)
|
||||||
# must be the access right of the parent form and not the linked object itself.
|
# must be the access right of the parent form and not the linked object itself.
|
||||||
records = dict(obj.name_get(cr, 1,
|
records = dict(obj.name_get(cr, SUPERUSER_ID,
|
||||||
list(set([x for x in res.values() if isinstance(x, (int,long))])),
|
list(set([x for x in res.values() if isinstance(x, (int,long))])),
|
||||||
context=context))
|
context=context))
|
||||||
for id in res:
|
for id in res:
|
||||||
|
@ -1200,7 +1201,7 @@ class related(function):
|
||||||
else:
|
else:
|
||||||
res = {}.fromkeys(ids, False)
|
res = {}.fromkeys(ids, False)
|
||||||
|
|
||||||
objlst = obj.browse(cr, 1, ids, context=context)
|
objlst = obj.browse(cr, SUPERUSER_ID, ids, context=context)
|
||||||
for data in objlst:
|
for data in objlst:
|
||||||
if not data:
|
if not data:
|
||||||
continue
|
continue
|
||||||
|
@ -1230,7 +1231,7 @@ class related(function):
|
||||||
# name_get as root, as seeing the name of a related
|
# name_get as root, as seeing the name of a related
|
||||||
# object depends on access right of source document,
|
# object depends on access right of source document,
|
||||||
# not target, so user may not have access.
|
# not target, so user may not have access.
|
||||||
ng = dict(obj.pool.get(self._obj).name_get(cr, 1, ids, context=context))
|
ng = dict(obj.pool.get(self._obj).name_get(cr, SUPERUSER_ID, ids, context=context))
|
||||||
for r in res:
|
for r in res:
|
||||||
if res[r]:
|
if res[r]:
|
||||||
res[r] = (res[r], ng[res[r]])
|
res[r] = (res[r], ng[res[r]])
|
||||||
|
@ -1495,7 +1496,7 @@ class property(function):
|
||||||
# not target, so user may not have access) in order to avoid
|
# not target, so user may not have access) in order to avoid
|
||||||
# pointing on an unexisting record.
|
# pointing on an unexisting record.
|
||||||
if property_destination_obj:
|
if property_destination_obj:
|
||||||
if res[id][prop_name] and obj.pool.get(property_destination_obj).exists(cr, 1, res[id][prop_name].id):
|
if res[id][prop_name] and obj.pool.get(property_destination_obj).exists(cr, SUPERUSER_ID, res[id][prop_name].id):
|
||||||
name_get_ids[id] = res[id][prop_name].id
|
name_get_ids[id] = res[id][prop_name].id
|
||||||
else:
|
else:
|
||||||
res[id][prop_name] = False
|
res[id][prop_name] = False
|
||||||
|
@ -1503,7 +1504,7 @@ class property(function):
|
||||||
# name_get as root (as seeing the name of a related
|
# name_get as root (as seeing the name of a related
|
||||||
# object depends on access right of source document,
|
# object depends on access right of source document,
|
||||||
# not target, so user may not have access.)
|
# not target, so user may not have access.)
|
||||||
name_get_values = dict(obj.pool.get(property_destination_obj).name_get(cr, 1, name_get_ids.values(), context=context))
|
name_get_values = dict(obj.pool.get(property_destination_obj).name_get(cr, SUPERUSER_ID, name_get_ids.values(), context=context))
|
||||||
# the property field is a m2o, we need to return a tuple with (id, name)
|
# the property field is a m2o, we need to return a tuple with (id, name)
|
||||||
for k, v in name_get_ids.iteritems():
|
for k, v in name_get_ids.iteritems():
|
||||||
if res[k][prop_name]:
|
if res[k][prop_name]:
|
||||||
|
|
|
@ -63,6 +63,7 @@ from openerp.tools.safe_eval import safe_eval as eval
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
from query import Query
|
from query import Query
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
_schema = logging.getLogger(__name__ + '.schema')
|
_schema = logging.getLogger(__name__ + '.schema')
|
||||||
|
@ -773,7 +774,7 @@ class BaseModel(object):
|
||||||
}
|
}
|
||||||
if getattr(f, 'serialization_field', None):
|
if getattr(f, 'serialization_field', None):
|
||||||
# resolve link to serialization_field if specified by name
|
# resolve link to serialization_field if specified by name
|
||||||
serialization_field_id = ir_model_fields_obj.search(cr, 1, [('model','=',vals['model']), ('name', '=', f.serialization_field)])
|
serialization_field_id = ir_model_fields_obj.search(cr, SUPERUSER_ID, [('model','=',vals['model']), ('name', '=', f.serialization_field)])
|
||||||
if not serialization_field_id:
|
if not serialization_field_id:
|
||||||
raise except_orm(_('Error'), _("Serialization field `%s` not found for sparse field `%s`!") % (f.serialization_field, k))
|
raise except_orm(_('Error'), _("Serialization field `%s` not found for sparse field `%s`!") % (f.serialization_field, k))
|
||||||
vals['serialization_field_id'] = serialization_field_id[0]
|
vals['serialization_field_id'] = serialization_field_id[0]
|
||||||
|
|
|
@ -40,6 +40,7 @@ import openerp.tools as tools
|
||||||
import openerp.modules
|
import openerp.modules
|
||||||
import openerp.exceptions
|
import openerp.exceptions
|
||||||
from openerp.service import http_server
|
from openerp.service import http_server
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
#.apidoc title: Exported Service methods
|
#.apidoc title: Exported Service methods
|
||||||
#.apidoc module-mods: member-order: bysource
|
#.apidoc module-mods: member-order: bysource
|
||||||
|
@ -72,8 +73,8 @@ def _initialize_db(serv, id, db_name, demo, lang, user_password):
|
||||||
|
|
||||||
if lang:
|
if lang:
|
||||||
modobj = pool.get('ir.module.module')
|
modobj = pool.get('ir.module.module')
|
||||||
mids = modobj.search(cr, 1, [('state', '=', 'installed')])
|
mids = modobj.search(cr, SUPERUSER_ID, [('state', '=', 'installed')])
|
||||||
modobj.update_translations(cr, 1, mids, lang)
|
modobj.update_translations(cr, SUPERUSER_ID, mids, lang)
|
||||||
|
|
||||||
cr.execute('UPDATE res_users SET password=%s, lang=%s, active=True WHERE login=%s', (
|
cr.execute('UPDATE res_users SET password=%s, lang=%s, active=True WHERE login=%s', (
|
||||||
user_password, lang, 'admin'))
|
user_password, lang, 'admin'))
|
||||||
|
|
|
@ -43,6 +43,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
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -214,7 +215,7 @@ class GettextAlias(object):
|
||||||
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)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
res = pool.get('ir.translation')._get_source(cr, 1, None, ('code','sql_constraint'), lang, source)
|
res = pool.get('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:
|
||||||
|
@ -872,7 +873,7 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True,
|
||||||
|
|
||||||
if not ids:
|
if not ids:
|
||||||
# lets create the language with locale information
|
# lets create the language with locale information
|
||||||
lang_obj.load_lang(cr, 1, lang=lang, lang_name=lang_name)
|
lang_obj.load_lang(cr, SUPERUSER_ID, lang=lang, lang_name=lang_name)
|
||||||
|
|
||||||
|
|
||||||
# now, the serious things: we read the language file
|
# now, the serious things: we read the language file
|
||||||
|
|
|
@ -13,6 +13,7 @@ import yaml_tag
|
||||||
import yaml
|
import yaml
|
||||||
import re
|
import re
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
# YAML import needs both safe and unsafe eval, but let's
|
# YAML import needs both safe and unsafe eval, but let's
|
||||||
# default to /safe/.
|
# default to /safe/.
|
||||||
|
@ -286,20 +287,20 @@ class YamlInterpreter(object):
|
||||||
|
|
||||||
view_id = record.view
|
view_id = record.view
|
||||||
if view_id and (view_id is not True):
|
if view_id and (view_id is not True):
|
||||||
view_id = self.pool.get('ir.model.data').get_object_reference(self.cr, 1, self.module, record.view)[1]
|
view_id = self.pool.get('ir.model.data').get_object_reference(self.cr, SUPERUSER_ID, self.module, record.view)[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, 1, self.module, record.id)
|
self.pool.get('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, 1, record.model, self.module, record.id)
|
id = self.pool.get('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)
|
||||||
|
@ -315,12 +316,12 @@ class YamlInterpreter(object):
|
||||||
if view_id:
|
if view_id:
|
||||||
varg = view_id
|
varg = view_id
|
||||||
if view_id is True: varg = False
|
if view_id is True: varg = False
|
||||||
view = model.fields_view_get(self.cr, 1, varg, 'form', context)
|
view = model.fields_view_get(self.cr, SUPERUSER_ID, varg, 'form', context)
|
||||||
view_id = etree.fromstring(view['arch'].encode('utf-8'))
|
view_id = etree.fromstring(view['arch'].encode('utf-8'))
|
||||||
|
|
||||||
record_dict = self._create_record(model, fields, view_id, default=default)
|
record_dict = self._create_record(model, fields, view_id, 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, 1, record.model, \
|
id = self.pool.get('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'):
|
||||||
|
@ -328,8 +329,8 @@ class YamlInterpreter(object):
|
||||||
|
|
||||||
def _create_record(self, model, fields, view=False, parent={}, default=True):
|
def _create_record(self, model, fields, view=False, parent={}, default=True):
|
||||||
if view is not False:
|
if view is not False:
|
||||||
defaults = default and model._add_missing_default_values(self.cr, 1, {}, context=self.context) or {}
|
defaults = default and model._add_missing_default_values(self.cr, SUPERUSER_ID, {}, context=self.context) or {}
|
||||||
fg = model.fields_get(self.cr, 1, context=self.context)
|
fg = model.fields_get(self.cr, SUPERUSER_ID, context=self.context)
|
||||||
else:
|
else:
|
||||||
defaults = {}
|
defaults = {}
|
||||||
fg = {}
|
fg = {}
|
||||||
|
@ -360,7 +361,7 @@ class YamlInterpreter(object):
|
||||||
if (view is not False) and (fg[field_name]['type']=='one2many'):
|
if (view is not False) and (fg[field_name]['type']=='one2many'):
|
||||||
view2 = view.find("field[@name='%s']/form"%(field_name,))
|
view2 = view.find("field[@name='%s']/form"%(field_name,))
|
||||||
if not view2:
|
if not view2:
|
||||||
view2 = self.pool.get(fg[field_name]['relation']).fields_view_get(self.cr, 1, False, 'form', self.context)
|
view2 = self.pool.get(fg[field_name]['relation']).fields_view_get(self.cr, SUPERUSER_ID, False, 'form', self.context)
|
||||||
view2 = etree.fromstring(view2['arch'].encode('utf-8'))
|
view2 = etree.fromstring(view2['arch'].encode('utf-8'))
|
||||||
|
|
||||||
field_value = self._eval_field(model, field_name, fields[field_name], view2, parent=record_dict, default=default)
|
field_value = self._eval_field(model, field_name, fields[field_name], view2, parent=record_dict, default=default)
|
||||||
|
@ -395,7 +396,7 @@ class YamlInterpreter(object):
|
||||||
|
|
||||||
# Evaluation args
|
# Evaluation args
|
||||||
args = map(lambda x: eval(x, ctx), match.group(2).split(','))
|
args = map(lambda x: eval(x, ctx), match.group(2).split(','))
|
||||||
result = getattr(model, match.group(1))(self.cr, 1, [], *args)
|
result = getattr(model, match.group(1))(self.cr, SUPERUSER_ID, [], *args)
|
||||||
for key, val in (result or {}).get('value', {}).items():
|
for key, val in (result or {}).get('value', {}).items():
|
||||||
if key not in fields:
|
if key not in fields:
|
||||||
assert key in fg, "The returning field '%s' from your on_change call '%s' does not exist on the object '%s'" % (key, match.group(1), model._name)
|
assert key in fg, "The returning field '%s' from your on_change call '%s' does not exist on the object '%s'" % (key, match.group(1), model._name)
|
||||||
|
@ -491,7 +492,7 @@ class YamlInterpreter(object):
|
||||||
python, statements = node.items()[0]
|
python, statements = node.items()[0]
|
||||||
model = self.get_model(python.model)
|
model = self.get_model(python.model)
|
||||||
statements = statements.replace("\r\n", "\n")
|
statements = statements.replace("\r\n", "\n")
|
||||||
code_context = {'model': model, 'cr': self.cr, 'uid': self.uid, 'log': self._log, 'context': self.context}
|
code_context = { 'model': model, 'cr': self.cr, 'uid': self.uid, 'log': self._log, 'context': self.context }
|
||||||
code_context.update({'self': model}) # remove me when no !python block test uses 'self' anymore
|
code_context.update({'self': model}) # remove me when no !python block test uses 'self' anymore
|
||||||
try:
|
try:
|
||||||
code_obj = compile(statements, self.filename, 'exec')
|
code_obj = compile(statements, self.filename, 'exec')
|
||||||
|
@ -655,7 +656,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, 1, \
|
pid = self.pool.get('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)
|
||||||
|
|
||||||
|
@ -666,7 +667,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, 1, 'action', \
|
self.pool.get('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):
|
||||||
|
@ -700,7 +701,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, 1, \
|
id = self.pool.get('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)
|
||||||
|
|
||||||
|
@ -708,7 +709,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, 1, 'action', keyword, \
|
self.pool.get('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
|
||||||
|
|
||||||
|
@ -729,7 +730,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, 1, \
|
id = self.pool.get('ir.model.data')._update(self.cr, SUPERUSER_ID, \
|
||||||
"ir.actions.url", self.module, res, node.id, mode=self.mode)
|
"ir.actions.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
|
||||||
|
@ -737,7 +738,7 @@ class YamlInterpreter(object):
|
||||||
keyword = node.keyword or 'client_action_multi'
|
keyword = node.keyword or 'client_action_multi'
|
||||||
value = 'ir.actions.url,%s' % id
|
value = 'ir.actions.url,%s' % id
|
||||||
replace = node.replace or True
|
replace = node.replace or True
|
||||||
self.pool.get('ir.model.data').ir_set(self.cr, 1, 'action', \
|
self.pool.get('ir.model.data').ir_set(self.cr, SUPERUSER_ID, 'action', \
|
||||||
keyword, node.url, ["ir.actions.url"], value, replace=replace, \
|
keyword, node.url, ["ir.actions.url"], value, replace=replace, \
|
||||||
noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
|
noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
|
||||||
|
|
||||||
|
@ -752,7 +753,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, 1, res['key'], res['key2'], \
|
self.pool.get('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))
|
||||||
|
|
||||||
|
@ -781,7 +782,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, 1, "ir.actions.report.xml", \
|
id = self.pool.get('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)
|
||||||
|
|
||||||
|
@ -789,7 +790,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, 1, 'action', \
|
self.pool.get('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):
|
||||||
|
|
Loading…
Reference in New Issue