[MERGE] trunk
bzr revid: fme@openerp.com-20120903124618-vpe2erkcml7131gp
|
@ -1185,6 +1185,9 @@
|
|||
<field name="model">ir.translation</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Translations" version="7.0">
|
||||
<header>
|
||||
<field name="state" widget="statusbar" nolabel="1"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
|
|
|
@ -35,6 +35,7 @@ from tools.config import config
|
|||
from tools.safe_eval import safe_eval as eval
|
||||
from tools.translate import _
|
||||
from socket import gethostname
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -271,7 +272,7 @@ class act_window(osv.osv):
|
|||
:return: A read() view of the ir.actions.act_window
|
||||
"""
|
||||
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
|
||||
return self.read(cr, uid, res_id, [], context)
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ from osv import osv,fields
|
|||
import uuid
|
||||
import datetime
|
||||
from tools import misc, config
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
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:
|
||||
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):
|
||||
"""Retrieve the value for a given key.
|
||||
|
|
|
@ -44,7 +44,7 @@ class ir_rule(osv.osv):
|
|||
def _eval_context(self, cr, uid):
|
||||
"""Returns a dictionary to use as evaluation context for
|
||||
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}
|
||||
|
||||
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.
|
||||
# This means also there is no implicit restriction (e.g. an object
|
||||
# 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 [], [], ['"'+self.pool.get(model_name)._table+'"']
|
||||
|
||||
|
|
|
@ -77,14 +77,14 @@ class ir_translation_import_cursor(object):
|
|||
def push(self, ddict):
|
||||
"""Feed a translation, as a dictionary, into the cursor
|
||||
"""
|
||||
|
||||
state = "translated" if (ddict['value'] and ddict['value'] != "") else "to_translate"
|
||||
self._cr.execute("INSERT INTO " + self._table_name \
|
||||
+ """(name, lang, res_id, src, type,
|
||||
imd_model, imd_module, imd_name, value)
|
||||
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
imd_model, imd_module, imd_name, value,state)
|
||||
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
(ddict['name'], ddict['lang'], ddict.get('res_id'), ddict['src'], ddict['type'],
|
||||
ddict.get('imd_model'), ddict.get('imd_module'), ddict.get('imd_name'),
|
||||
ddict['value']))
|
||||
ddict['value'],state))
|
||||
|
||||
def finish(self):
|
||||
""" Transfer the data from the temp table to ir.translation
|
||||
|
@ -125,15 +125,16 @@ class ir_translation_import_cursor(object):
|
|||
# Step 2: update existing (matching) translations
|
||||
if self._overwrite:
|
||||
cr.execute("""UPDATE ONLY %s AS irt
|
||||
SET value = ti.value
|
||||
SET value = ti.value,
|
||||
state = 'translated'
|
||||
FROM %s AS ti
|
||||
WHERE %s AND ti.value IS NOT NULL AND ti.value != ''
|
||||
""" % (self._parent_table, self._table_name, find_expr))
|
||||
|
||||
# Step 3: insert new translations
|
||||
|
||||
cr.execute("""INSERT INTO %s(name, lang, res_id, src, type, value)
|
||||
SELECT name, lang, res_id, src, type, value
|
||||
cr.execute("""INSERT INTO %s(name, lang, res_id, src, type, value,state)
|
||||
SELECT name, lang, res_id, src, type, value,state
|
||||
FROM %s AS ti
|
||||
WHERE NOT EXISTS(SELECT 1 FROM ONLY %s AS irt WHERE %s);
|
||||
""" % (self._parent_table, self._table_name, self._parent_table, find_expr))
|
||||
|
@ -167,6 +168,11 @@ class ir_translation(osv.osv):
|
|||
'type': fields.selection(TRANSLATION_TYPE, string='Type', size=16, select=True),
|
||||
'src': fields.text('Source'),
|
||||
'value': fields.text('Translation Value'),
|
||||
'state':fields.selection([('to_translate','To Translate'),('inprogress','Translation in Progress'),('translated','Translated')])
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state':'to_translate',
|
||||
}
|
||||
|
||||
_sql_constraints = [ ('lang_fkey_res_lang', 'FOREIGN KEY(lang) REFERENCES res_lang(code)',
|
||||
|
@ -301,6 +307,10 @@ class ir_translation(osv.osv):
|
|||
context = {}
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
if vals.get('src') or ('value' in vals and not(vals.get('value'))):
|
||||
result = vals.update({'state':'to_translate'})
|
||||
if vals.get('value'):
|
||||
result = vals.update({'state':'translated'})
|
||||
result = super(ir_translation, self).write(cursor, user, ids, vals, context=context)
|
||||
for trans_obj in self.read(cursor, user, ids, ['name','type','res_id','src','lang'], context=context):
|
||||
self._get_source.clear_cache(self, user, trans_obj['name'], trans_obj['type'], trans_obj['lang'], trans_obj['src'])
|
||||
|
|
|
@ -28,6 +28,7 @@ import tools
|
|||
import openerp.modules
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
def one_in(setA, 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:
|
||||
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 = []
|
||||
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)
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
<field name="lang"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="act_cancel" special="cancel" string="Cancel" type="object"/>
|
||||
<button name="act_update" string="Update" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button name="act_cancel" special="cancel" string="Cancel" type="object" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
@ -24,6 +24,7 @@ from osv import fields
|
|||
import os
|
||||
import tools
|
||||
import openerp
|
||||
from openerp import SUPERUSER_ID
|
||||
from tools.translate import _
|
||||
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,
|
||||
# which are probably to allow to see the child companies) even if
|
||||
# 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]))
|
||||
return cmp_ids
|
||||
return super(res_company, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
|
||||
|
|
|
@ -225,12 +225,24 @@ class res_partner(osv.osv):
|
|||
return [context['category_id']]
|
||||
return False
|
||||
|
||||
def _get_default_image(self, cr, uid, is_company, context=None):
|
||||
def _get_default_image(self, cr, uid, is_company, context=None, colorize=False):
|
||||
if is_company:
|
||||
image_path = openerp.modules.get_module_resource('base', 'static/src/img', 'company_image.png')
|
||||
image = open(openerp.modules.get_module_resource('base', 'static/src/img', 'company_image.png')).read()
|
||||
else:
|
||||
image_path = openerp.modules.get_module_resource('base', 'static/src/img', 'partner_image.png')
|
||||
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
|
||||
from PIL import Image
|
||||
from StringIO import StringIO
|
||||
color = (255,255,255)
|
||||
if colorize:
|
||||
from random import random
|
||||
color = (int(random() * 192 + 32), int(random() * 192 + 32), int(random() * 192 + 32))
|
||||
face = Image.open(openerp.modules.get_module_resource('base', 'static/src/img', 'avatar.png'))
|
||||
avatar = Image.new('RGB', face.size)
|
||||
avatar.paste(color)
|
||||
avatar.paste(face, mask=face)
|
||||
buffer = StringIO()
|
||||
avatar.save(buffer, 'PNG')
|
||||
image = buffer.getvalue()
|
||||
return image.encode('base64')
|
||||
|
||||
_defaults = {
|
||||
'active': True,
|
||||
|
@ -243,9 +255,7 @@ class res_partner(osv.osv):
|
|||
'is_company': False,
|
||||
'type': 'default',
|
||||
'use_parent_address': True,
|
||||
'image': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context),
|
||||
'image_small': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context),
|
||||
'image_medium': lambda self, cr, uid, context: self._get_default_image(cr, uid, False, context),
|
||||
'image': lambda self, cr, uid, context: self._get_default_image(cr, uid, context.get('default_is_company', False), context),
|
||||
}
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
@ -323,9 +333,6 @@ class res_partner(osv.osv):
|
|||
domain_siblings = [('parent_id', '=', vals['parent_id']), ('use_parent_address', '=', True)]
|
||||
update_ids = [vals['parent_id']] + self.search(cr, uid, domain_siblings, context=context)
|
||||
self.update_address(cr, uid, update_ids, vals, context)
|
||||
if 'image' not in vals :
|
||||
image_value = self._get_default_image(cr, uid, vals.get('is_company', False) or context.get('default_is_company'), context)
|
||||
vals.update(tools.image_get_resized_images(image_value, return_big=True))
|
||||
return super(res_partner,self).create(cr, uid, vals, context=context)
|
||||
|
||||
def update_address(self, cr, uid, ids, vals, context=None):
|
||||
|
@ -369,18 +376,17 @@ class res_partner(osv.osv):
|
|||
email_regex = re.compile('([a-zA-Z0-9._%-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9._]{1,8})')
|
||||
contact_regex_res = contact_regex.findall(name)
|
||||
email_regex_res = email_regex.findall(name)
|
||||
email = False
|
||||
if contact_regex_res:
|
||||
name = contact_regex_res[0][0].rstrip(' ') # remove extra spaces on the right
|
||||
email = contact_regex_res[0][1]
|
||||
rec_id = self.create(cr, uid, {self._rec_name: name, 'email': email}, context);
|
||||
return self.name_get(cr, uid, [rec_id], context)[0]
|
||||
elif email_regex_res:
|
||||
email = '%s' % (email_regex_res[0])
|
||||
rec_id = self.create(cr, uid, {self._rec_name: email, 'email': email}, context);
|
||||
return self.name_get(cr, uid, [rec_id], context)[0]
|
||||
else:
|
||||
rec_id = super(res_partner, self).create(cr, uid, {self._rec_name: name}, context)
|
||||
return self.name_get(cr, uid, [rec_id], context)[0]
|
||||
pass
|
||||
data = {self._rec_name: name, 'email': email}
|
||||
rec_id = self.create(cr, uid, data, context);
|
||||
return self.name_get(cr, uid, [rec_id], context)[0]
|
||||
|
||||
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
|
||||
if not args:
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Partners" version="7.0">
|
||||
<sheet>
|
||||
<field name="image" widget='image' class="oe_left" options='{"preview_image": "image_medium", "size": [90, 90]}'/>
|
||||
<field name="image" widget='image' class="oe_left oe_avatar" options='{"preview_image": "image_medium", "size": [90, 90]}'/>
|
||||
<div class="oe_title">
|
||||
<div class="oe_edit_only">
|
||||
<label for="name"/> (
|
||||
|
|
|
@ -26,6 +26,7 @@ import logging
|
|||
from lxml import etree
|
||||
from lxml.builder import E
|
||||
import netsvc
|
||||
from openerp import SUPERUSER_ID
|
||||
import openerp
|
||||
import openerp.exceptions
|
||||
from osv import fields,osv
|
||||
|
@ -188,7 +189,7 @@ class res_users(osv.osv):
|
|||
result = super(res_users, self).read(cr, uid, ids, fields, context, load)
|
||||
canwrite = self.pool.get('ir.model.access').check(cr, uid, 'res.users', 'write', False)
|
||||
if not canwrite:
|
||||
if isinstance(ids, (int, float)):
|
||||
if isinstance(ids, (int, long)):
|
||||
result = override_password(result)
|
||||
else:
|
||||
result = map(override_password, result)
|
||||
|
@ -206,11 +207,6 @@ class res_users(osv.osv):
|
|||
('login_key', 'UNIQUE (login)', 'You can not have two users with the same login !')
|
||||
]
|
||||
|
||||
def _get_default_image(self, cr, uid, context=None):
|
||||
""" Override of res.partner: multicolor avatars ! """
|
||||
image_path = openerp.modules.get_module_resource('base', 'static/src/img', 'avatar%d.png' % random.randint(0, 6))
|
||||
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
|
||||
|
||||
def _get_company(self,cr, uid, context=None, uid2=False):
|
||||
if not uid2:
|
||||
uid2 = uid
|
||||
|
@ -238,9 +234,9 @@ class res_users(osv.osv):
|
|||
dataobj = self.pool.get('ir.model.data')
|
||||
result = []
|
||||
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)
|
||||
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)
|
||||
except ValueError:
|
||||
# If these groups does not exists anymore
|
||||
|
@ -255,7 +251,7 @@ class res_users(osv.osv):
|
|||
'company_id': _get_company,
|
||||
'company_ids': _get_companies,
|
||||
'groups_id': _get_group,
|
||||
'image': lambda self, cr, uid, context: self._get_default_image(cr, uid, context),
|
||||
'image': lambda self, cr, uid, context: self.pool.get('res.partner')._get_default_image(cr, uid, False, context, colorize=True),
|
||||
}
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
|
@ -280,7 +276,7 @@ class res_users(osv.osv):
|
|||
break
|
||||
else:
|
||||
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']
|
||||
uid = 1 # safe fields only, so we write as super-user to bypass access rights
|
||||
|
||||
|
@ -332,7 +328,7 @@ class res_users(osv.osv):
|
|||
return super(res_users, self).copy(cr, uid, id, copydef, context)
|
||||
|
||||
def context_get(self, cr, uid, context=None):
|
||||
user = self.browse(cr, 1, uid, context)
|
||||
user = self.browse(cr, SUPERUSER_ID, uid, context)
|
||||
result = {}
|
||||
for k in self._all_columns.keys():
|
||||
if k.startswith('context_'):
|
||||
|
@ -350,7 +346,7 @@ class res_users(osv.osv):
|
|||
|
||||
def action_get(self, cr, uid, context=None):
|
||||
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
|
||||
|
||||
def check_super(self, passwd):
|
||||
|
@ -361,7 +357,7 @@ class res_users(osv.osv):
|
|||
|
||||
def check_credentials(self, cr, uid, password):
|
||||
""" 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:
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
|
||||
|
@ -377,7 +373,7 @@ class res_users(osv.osv):
|
|||
# of them rolled back due to a concurrent access.)
|
||||
cr.autocommit(True)
|
||||
# check if user exists
|
||||
res = self.search(cr, 1, [('login','=',login)])
|
||||
res = self.search(cr, SUPERUSER_ID, [('login','=',login)])
|
||||
if res:
|
||||
user_id = res[0]
|
||||
# check credentials
|
||||
|
@ -542,7 +538,7 @@ class groups_implied(osv.osv):
|
|||
return memo[g]
|
||||
|
||||
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))
|
||||
return res
|
||||
|
||||
|
@ -687,7 +683,7 @@ class groups_view(osv.osv):
|
|||
|
||||
def get_user_groups_view(self, cr, uid, context=None):
|
||||
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'
|
||||
except Exception:
|
||||
view = False
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
<form string="Users" version="7.0">
|
||||
<field name="id" invisible="1"/>
|
||||
<sheet>
|
||||
<field name="image_medium" widget='image' class="oe_avatar oe_left"/>
|
||||
<field name="image" widget='image' class="oe_avatar oe_left" options='{"preview_image": "image_medium"}'/>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name"/></h1>
|
||||
|
@ -195,9 +195,7 @@
|
|||
<field eval="18" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Users" version="7.0">
|
||||
<div class="oe_right oe_avatar">
|
||||
<field name="image_small" widget='image' class="oe_image_small"/>
|
||||
</div>
|
||||
<field name="image" widget='image' class="oe_right oe_avatar" options='{"preview_image": "image_small"}'/>
|
||||
<h1>
|
||||
<field name="name" readonly="1" class="oe_inline"/>
|
||||
(<field name="login" readonly="1" class="oe_inline"/>)
|
||||
|
|
After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 2.7 KiB |
|
@ -39,6 +39,7 @@ import openerp.pooler as pooler
|
|||
import openerp.release as release
|
||||
import openerp.tools as tools
|
||||
import openerp.tools.assertion_report as assertion_report
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
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')
|
||||
if ('base' in tools.config['init']) or ('base' in tools.config['update']):
|
||||
_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()))
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ from openerp.tools.translate import _
|
|||
from openerp.tools import float_round, float_repr
|
||||
import simplejson
|
||||
from openerp.tools.html_sanitize import html_sanitize
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
_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}
|
||||
# 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.
|
||||
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))])),
|
||||
context=context))
|
||||
for id in res:
|
||||
|
@ -1200,7 +1201,7 @@ class related(function):
|
|||
else:
|
||||
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:
|
||||
if not data:
|
||||
continue
|
||||
|
@ -1230,7 +1231,7 @@ class related(function):
|
|||
# name_get as root, as seeing the name of a related
|
||||
# object depends on access right of source document,
|
||||
# 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:
|
||||
if 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
|
||||
# pointing on an unexisting record.
|
||||
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
|
||||
else:
|
||||
res[id][prop_name] = False
|
||||
|
@ -1503,7 +1504,7 @@ class property(function):
|
|||
# name_get as root (as seeing the name of a related
|
||||
# object depends on access right of source document,
|
||||
# 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)
|
||||
for k, v in name_get_ids.iteritems():
|
||||
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 import SUPERUSER_ID
|
||||
from query import Query
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_schema = logging.getLogger(__name__ + '.schema')
|
||||
|
@ -773,7 +774,7 @@ class BaseModel(object):
|
|||
}
|
||||
if getattr(f, 'serialization_field', None):
|
||||
# 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:
|
||||
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]
|
||||
|
|
|
@ -40,6 +40,7 @@ import openerp.tools as tools
|
|||
import openerp.modules
|
||||
import openerp.exceptions
|
||||
from openerp.service import http_server
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
#.apidoc title: Exported Service methods
|
||||
#.apidoc module-mods: member-order: bysource
|
||||
|
@ -72,8 +73,8 @@ def _initialize_db(serv, id, db_name, demo, lang, user_password):
|
|||
|
||||
if lang:
|
||||
modobj = pool.get('ir.module.module')
|
||||
mids = modobj.search(cr, 1, [('state', '=', 'installed')])
|
||||
modobj.update_translations(cr, 1, mids, lang)
|
||||
mids = modobj.search(cr, SUPERUSER_ID, [('state', '=', 'installed')])
|
||||
modobj.update_translations(cr, SUPERUSER_ID, mids, lang)
|
||||
|
||||
cr.execute('UPDATE res_users SET password=%s, lang=%s, active=True WHERE login=%s', (
|
||||
user_password, lang, 'admin'))
|
||||
|
|
|
@ -43,6 +43,7 @@ import misc
|
|||
from misc import UpdateableStr
|
||||
from misc import SKIPPED_ELEMENT_TYPES
|
||||
import osutil
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -214,7 +215,7 @@ class GettextAlias(object):
|
|||
if cr:
|
||||
# Try to use ir.translation to benefit from global cache if possible
|
||||
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:
|
||||
_logger.debug('no context cursor detected, skipping translation for "%r"', source)
|
||||
else:
|
||||
|
@ -872,7 +873,7 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True,
|
|||
|
||||
if not ids:
|
||||
# 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
|
||||
|
|
|
@ -13,6 +13,7 @@ import yaml_tag
|
|||
import yaml
|
||||
import re
|
||||
from lxml import etree
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
# YAML import needs both safe and unsafe eval, but let's
|
||||
# default to /safe/.
|
||||
|
@ -286,20 +287,20 @@ class YamlInterpreter(object):
|
|||
|
||||
view_id = record.view
|
||||
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():
|
||||
record_dict=self.create_osv_memory_record(record, fields)
|
||||
else:
|
||||
self.validate_xml_id(record.id)
|
||||
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
|
||||
except ValueError:
|
||||
default = True
|
||||
|
||||
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
|
||||
if id:
|
||||
self.id_map[record] = int(id)
|
||||
|
@ -315,12 +316,12 @@ class YamlInterpreter(object):
|
|||
if view_id:
|
||||
varg = view_id
|
||||
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'))
|
||||
|
||||
record_dict = self._create_record(model, fields, view_id, default=default)
|
||||
_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.id_map[record.id] = int(id)
|
||||
if config.get('import_partial'):
|
||||
|
@ -328,8 +329,8 @@ class YamlInterpreter(object):
|
|||
|
||||
def _create_record(self, model, fields, view=False, parent={}, default=True):
|
||||
if view is not False:
|
||||
defaults = default and model._add_missing_default_values(self.cr, 1, {}, context=self.context) or {}
|
||||
fg = model.fields_get(self.cr, 1, context=self.context)
|
||||
defaults = default and model._add_missing_default_values(self.cr, SUPERUSER_ID, {}, context=self.context) or {}
|
||||
fg = model.fields_get(self.cr, SUPERUSER_ID, context=self.context)
|
||||
else:
|
||||
defaults = {}
|
||||
fg = {}
|
||||
|
@ -360,7 +361,7 @@ class YamlInterpreter(object):
|
|||
if (view is not False) and (fg[field_name]['type']=='one2many'):
|
||||
view2 = view.find("field[@name='%s']/form"%(field_name,))
|
||||
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'))
|
||||
|
||||
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
|
||||
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():
|
||||
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)
|
||||
|
@ -491,7 +492,7 @@ class YamlInterpreter(object):
|
|||
python, statements = node.items()[0]
|
||||
model = self.get_model(python.model)
|
||||
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
|
||||
try:
|
||||
code_obj = compile(statements, self.filename, 'exec')
|
||||
|
@ -655,7 +656,7 @@ class YamlInterpreter(object):
|
|||
|
||||
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, \
|
||||
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_id = self.get_id(node.action)
|
||||
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)
|
||||
|
||||
def process_act_window(self, node):
|
||||
|
@ -700,7 +701,7 @@ class YamlInterpreter(object):
|
|||
|
||||
if 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)
|
||||
self.id_map[node.id] = int(id)
|
||||
|
||||
|
@ -708,7 +709,7 @@ class YamlInterpreter(object):
|
|||
keyword = 'client_action_relate'
|
||||
value = 'ir.actions.act_window,%s' % id
|
||||
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)
|
||||
# TODO add remove ir.model.data
|
||||
|
||||
|
@ -729,7 +730,7 @@ class YamlInterpreter(object):
|
|||
|
||||
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)
|
||||
self.id_map[node.id] = int(id)
|
||||
# ir_set
|
||||
|
@ -737,7 +738,7 @@ class YamlInterpreter(object):
|
|||
keyword = node.keyword or 'client_action_multi'
|
||||
value = 'ir.actions.url,%s' % id
|
||||
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, \
|
||||
noupdate=self.isnoupdate(node), isobject=True, xml_id=node.id)
|
||||
|
||||
|
@ -752,7 +753,7 @@ class YamlInterpreter(object):
|
|||
else:
|
||||
value = expression
|
||||
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), \
|
||||
isobject=res.get('isobject', False), meta=res.get('meta',None))
|
||||
|
||||
|
@ -781,7 +782,7 @@ class YamlInterpreter(object):
|
|||
|
||||
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.id_map[xml_id] = int(id)
|
||||
|
||||
|
@ -789,7 +790,7 @@ class YamlInterpreter(object):
|
|||
keyword = node.keyword or 'client_print_multi'
|
||||
value = 'ir.actions.report.xml,%s' % id
|
||||
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)
|
||||
|
||||
def process_none(self):
|
||||
|
@ -810,8 +811,6 @@ class YamlInterpreter(object):
|
|||
is_preceded_by_comment = self._log_node(node, is_preceded_by_comment)
|
||||
try:
|
||||
self._process_node(node)
|
||||
except YamlImportException, e:
|
||||
_logger.exception(e)
|
||||
except Exception, e:
|
||||
_logger.exception(e)
|
||||
raise
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
DATABASE=trunk
|
||||
dropdb ${DATABASE}
|
||||
REPOSITORIES=../../addons/trunk
|
||||
MODULES=`python -c "import os; print ','.join(os.listdir('${REPOSITORIES}'))"`
|
||||
createdb ${DATABASE}
|
||||
rm openerp-server.log
|
||||
./openerp-server \
|
||||
--log-level=debug \
|
||||
--addons=${REPOSITORIES},../../web/trunk/addons \
|
||||
-d ${DATABASE} \
|
||||
-i ${MODULES} \
|
||||
--stop-after-init \
|
||||
--no-xmlrpc \
|
||||
--no-xmlrpcs \
|
||||
--no-netrpc \
|
||||
--test-enable \
|
||||
--logfile=openerp-server.log
|