bzr revid: nicolas.vanhoren@openerp.com-20101026100039-dc9ev9f6lgbw3r66
This commit is contained in:
nvi-openerp 2010-10-26 12:00:39 +02:00
commit 5b7affd49f
8 changed files with 7549 additions and 3899 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,13 +7,13 @@ msgstr ""
"Project-Id-Version: OpenERP Server 5.0.4\n" "Project-Id-Version: OpenERP Server 5.0.4\n"
"Report-Msgid-Bugs-To: support@openerp.com\n" "Report-Msgid-Bugs-To: support@openerp.com\n"
"POT-Creation-Date: 2010-10-18 17:46+0000\n" "POT-Creation-Date: 2010-10-18 17:46+0000\n"
"PO-Revision-Date: 2010-10-24 15:16+0000\n" "PO-Revision-Date: 2010-10-25 07:03+0000\n"
"Last-Translator: Chertykov Denis <chertykov@gmail.com>\n" "Last-Translator: Chertykov Denis <chertykov@gmail.com>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-10-25 04:38+0000\n" "X-Launchpad-Export-Date: 2010-10-26 04:36+0000\n"
"X-Generator: Launchpad (build Unknown)\n" "X-Generator: Launchpad (build Unknown)\n"
#. module: base #. module: base

View File

@ -253,7 +253,8 @@ class act_window(osv.osv):
'search_view' : fields.function(_search_view, type='text', method=True, string='Search View'), 'search_view' : fields.function(_search_view, type='text', method=True, string='Search View'),
'menus': fields.char('Menus', size=4096), 'menus': fields.char('Menus', size=4096),
'help': fields.text('Action description', 'help': fields.text('Action description',
help='Optional help text for the users with a description of the target view, such as its usage and purpose.'), help='Optional help text for the users with a description of the target view, such as its usage and purpose.',
translate=True),
'display_menu_tip':fields.function(_get_help_status, type='boolean', method=True, string='Display Menu Tips', 'display_menu_tip':fields.function(_get_help_status, type='boolean', method=True, string='Display Menu Tips',
help='It gives the status if the tip has to be displayed or not when a user executes an action'), help='It gives the status if the tip has to be displayed or not when a user executes an action'),
'multi': fields.boolean('Action on Multiple Doc.', help="If set to true, the action will not be displayed on the right toolbar of a form view"), 'multi': fields.boolean('Action on Multiple Doc.', help="If set to true, the action will not be displayed on the right toolbar of a form view"),

View File

@ -1286,7 +1286,6 @@ class orm_template(object):
'fields': xfields 'fields': xfields
} }
attrs = {'views': views} attrs = {'views': views}
view = False
fields = views.get('field', False) and views['field'].get('fields', False) fields = views.get('field', False) and views['field'].get('fields', False)
if node.get('name'): if node.get('name'):
attrs = {} attrs = {}
@ -2212,7 +2211,6 @@ class orm(orm_template):
fget = self.fields_get(cr, uid, fields) fget = self.fields_get(cr, uid, fields)
float_int_fields = filter(lambda x: fget[x]['type'] in ('float', 'integer'), fields) float_int_fields = filter(lambda x: fget[x]['type'] in ('float', 'integer'), fields)
sum = {}
flist = '' flist = ''
group_by = groupby group_by = groupby
if groupby: if groupby:
@ -2233,10 +2231,10 @@ class orm(orm_template):
or (f in self._columns and getattr(self._columns[f], '_classic_write'))] or (f in self._columns and getattr(self._columns[f], '_classic_write'))]
for f in fields_pre: for f in fields_pre:
if f not in ['id', 'sequence']: if f not in ['id', 'sequence']:
operator = fget[f].get('group_operator', 'sum') group_operator = fget[f].get('group_operator', 'sum')
if flist: if flist:
flist += ',' flist += ','
flist += operator+'('+f+') as '+f flist += group_operator+'('+f+') as '+f
gb = groupby and (' GROUP BY '+groupby) or '' gb = groupby and (' GROUP BY '+groupby) or ''
@ -2971,26 +2969,6 @@ class orm(orm_template):
for key, v in r.items(): for key, v in r.items():
if v is None: if v is None:
r[key] = False r[key] = False
if key in self._columns:
column = self._columns[key]
elif key in self._inherit_fields:
column = self._inherit_fields[key][2]
else:
continue
# TODO: removed this, it's too slow
# if v and column._type == 'reference':
# model_name, ref_id = v.split(',', 1)
# model = self.pool.get(model_name)
# if not model:
# reset = True
# else:
# cr.execute('SELECT count(1) FROM "%s" WHERE id=%%s' % (model._table,), (ref_id,))
# reset = not cr.fetchone()[0]
# if reset:
# if column._classic_write:
# query = 'UPDATE "%s" SET "%s"=NULL WHERE id=%%s' % (self._table, key)
# cr.execute(query, (r['id'],))
# r[key] = False
if isinstance(ids, (int, long, dict)): if isinstance(ids, (int, long, dict)):
return result and result[0] or False return result and result[0] or False
@ -3213,17 +3191,21 @@ class orm(orm_template):
return return
if not (context.get(self.CONCURRENCY_CHECK_FIELD) and self._log_access): if not (context.get(self.CONCURRENCY_CHECK_FIELD) and self._log_access):
return return
def key(oid): check_clause = "(id = %s AND %s < COALESCE(write_date, create_date, now())::timestamp)"
return "%s,%s" % (self._name, oid) for sub_ids in cr.split_for_in_conditions(ids):
santa = "(id = %s AND %s < COALESCE(write_date, create_date, now())::timestamp)" ids_to_check = []
for i in range(0, len(ids), cr.IN_MAX): for id in sub_ids:
sub_ids = tools.flatten(((oid, context[self.CONCURRENCY_CHECK_FIELD][key(oid)]) id_ref = "%s,%s" % (self._name, id)
for oid in ids[i:i+cr.IN_MAX] update_date = context[self.CONCURRENCY_CHECK_FIELD].pop(id_ref, None)
if key(oid) in context[self.CONCURRENCY_CHECK_FIELD])) if update_date:
if not sub_ids: continue ids_to_check.extend([id, update_date])
cr.execute("SELECT 1 FROM %s WHERE %s" % (self._table, " OR ".join([santa]*(len(sub_ids)/2))), sub_ids) if not ids_to_check:
if cr.fetchone(): continue
raise except_orm('ConcurrencyException', _('Records were modified in the meanwhile')) cr.execute("SELECT id FROM %s WHERE %s" % (self._table, " OR ".join([check_clause]*(len(ids_to_check)/2))), tuple(ids_to_check))
res = cr.fetchone()
if res:
# mention the first one only to keep the error message readable
raise except_orm('ConcurrencyException', _('A document was modified since you last viewed it (%s:%d)') % (self._description, res[0]))
def check_access_rule(self, cr, uid, ids, operation, context=None): def check_access_rule(self, cr, uid, ids, operation, context=None):
"""Verifies that the operation given by ``operation`` is allowed for the user """Verifies that the operation given by ``operation`` is allowed for the user

View File

@ -55,7 +55,8 @@ _EXPR_OPCODES = _CONST_OPCODES.union(set(opmap[x] for x in [
_SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [ _SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [
'STORE_MAP', 'LOAD_NAME', 'CALL_FUNCTION', 'COMPARE_OP', 'LOAD_ATTR', 'STORE_MAP', 'LOAD_NAME', 'CALL_FUNCTION', 'COMPARE_OP', 'LOAD_ATTR',
'STORE_NAME', 'GET_ITER', 'FOR_ITER', 'LIST_APPEND', 'JUMP_ABSOLUTE', 'STORE_NAME', 'GET_ITER', 'FOR_ITER', 'LIST_APPEND', 'JUMP_ABSOLUTE',
'DELETE_NAME', 'JUMP_IF_TRUE', 'JUMP_IF_FALSE','MAKE_FUNCTION','JUMP_FORWARD' 'DELETE_NAME', 'JUMP_IF_TRUE', 'JUMP_IF_FALSE','MAKE_FUNCTION','JUMP_FORWARD',
'SLICE+0', 'SLICE+1', 'SLICE+2', 'SLICE+3'
] if x in opmap)) ] if x in opmap))
_logger = logging.getLogger('safe_eval') _logger = logging.getLogger('safe_eval')

View File

@ -303,7 +303,7 @@ class YamlInterpreter(object):
else: else:
self.validate_xml_id(record.id) self.validate_xml_id(record.id)
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, self.uid, record.model, self.module, record.id) id = self.pool.get('ir.model.data')._update_dummy(self.cr, 1, 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)
@ -316,7 +316,7 @@ class YamlInterpreter(object):
self.logger.debug("RECORD_DICT %s" % record_dict) self.logger.debug("RECORD_DICT %s" % record_dict)
#context = self.get_context(record, self.eval_context) #context = self.get_context(record, self.eval_context)
context = record.context #TOFIX: record.context like {'withoutemployee':True} should pass from self.eval_context. example: test_project.yml in project module context = record.context #TOFIX: record.context like {'withoutemployee':True} should pass from self.eval_context. example: test_project.yml in project module
id = self.pool.get('ir.model.data')._update(self.cr, self.uid, record.model, \ id = self.pool.get('ir.model.data')._update(self.cr, 1, 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'):
@ -569,7 +569,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, self.uid, \ pid = self.pool.get('ir.model.data')._update(self.cr, 1, \
'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)
@ -580,7 +580,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, self.uid, 'action', \ self.pool.get('ir.model.data').ir_set(self.cr, 1, '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):
@ -614,7 +614,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, self.uid, \ id = self.pool.get('ir.model.data')._update(self.cr, 1, \
'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)
@ -622,7 +622,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, self.uid, 'action', keyword, \ self.pool.get('ir.model.data').ir_set(self.cr, 1, '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
@ -635,7 +635,7 @@ class YamlInterpreter(object):
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.get(node.model).unlink(self.cr, self.uid, ids)
self.pool.get('ir.model.data')._unlink(self.cr, self.uid, node.model, ids) self.pool.get('ir.model.data')._unlink(self.cr, 1, node.model, ids)
else: else:
self.logger.log(logging.TEST, "Record not deleted.") self.logger.log(logging.TEST, "Record not deleted.")
@ -644,7 +644,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, self.uid, \ id = self.pool.get('ir.model.data')._update(self.cr, 1, \
"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
@ -652,7 +652,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, self.uid, 'action', \ self.pool.get('ir.model.data').ir_set(self.cr, 1, '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)
@ -667,7 +667,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, self.uid, res['key'], res['key2'], \ self.pool.get('ir.model.data').ir_set(self.cr, 1, 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))
@ -692,7 +692,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, self.uid, "ir.actions.report.xml", \ id = self.pool.get('ir.model.data')._update(self.cr, 1, "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)
@ -700,7 +700,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, self.uid, 'action', \ self.pool.get('ir.model.data').ir_set(self.cr, 1, '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):

View File

@ -4,7 +4,7 @@ import logging
class YamlTag(object): class YamlTag(object):
""" """
Superclass for constructors of custom tags defined in yaml file. Superclass for constructors of custom tags defined in yaml file.
__str__ are overriden in subclass and used for serialization in module recorder. __str__ is overriden in subclass and used for serialization in module recorder.
""" """
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
@ -89,14 +89,14 @@ class Eval(YamlTag):
self.expression = expression self.expression = expression
super(Eval, self).__init__() super(Eval, self).__init__()
def __str__(self): def __str__(self):
return 'eval(%s)' % (str(self.expr,)) return '!eval %s' % str(self.expression)
class Ref(YamlTag): class Ref(YamlTag):
def __init__(self, expr="False", *args, **kwargs): def __init__(self, expr="False", *args, **kwargs):
self.expr = expr self.expr = expr
super(Ref, self).__init__(*args, **kwargs) super(Ref, self).__init__(*args, **kwargs)
def __str__(self): def __str__(self):
return 'ref(%s)' % (str(self.expr,)) return 'ref(%s)' % repr(self.expr)
class IrSet(YamlTag): class IrSet(YamlTag):
def __init__(self): def __init__(self):