From 9effe4fa6d6a0f93e0b53930a7f32ba9a7fe550a Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 28 Mar 2011 09:59:20 +0200 Subject: [PATCH 1/3] [IMP] tools: add "unquote" class for magic bare variables in context/domains This is used to allow bare active_id variables in context or domains of act_window tags. Note that previously this was done by replacing the active_id with a active_id string, which required further trick on the client side to perform the reverse operation. bzr revid: odo@openerp.com-20110328075920-ljadcubezs9swli8 --- openerp/tools/convert.py | 20 +++++++++++++++++++- openerp/tools/misc.py | 19 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py index 6f91a955cc6..5536f311eb8 100644 --- a/openerp/tools/convert.py +++ b/openerp/tools/convert.py @@ -50,6 +50,8 @@ from yaml_import import convert_yaml_import # List of etree._Element subclasses that we choose to ignore when parsing XML. from misc import SKIPPED_ELEMENT_TYPES +from misc import unquote + # Import of XML records requires the unsafe eval as well, # almost everywhere, which is ok because it supposedly comes # from trusted data, but at least we make it obvious now. @@ -439,7 +441,21 @@ form: module.record_id""" % (xml_id,) limit = rec.get('limit','').encode('utf-8') auto_refresh = rec.get('auto_refresh','').encode('utf-8') uid = self.uid - active_id = str("active_id") # for further reference in client/bin/tools/__init__.py + + # Act_window's 'domain' and 'context' contain mostly literals + # but they can also refer to the variables provided below + # in eval_context, so we need to eval() them before storing. + # Among the context variables, 'active_id' refers to + # the currently selected items in a list view, and only + # takes meaning at runtime on the client side. For this + # reason it must remain a bare variable in domain and context, + # even after eval() at server-side. We use the special 'unquote' + # class to achieve this effect: a string which has itself, unquoted, + # as representation. + active_id = unquote("active_id") + active_ids = unquote("active_ids") + active_model = unquote("active_model") + def ref(str_id): return self.id_get(cr, str_id) @@ -459,6 +475,8 @@ form: module.record_id""" % (xml_id,) 'auto_refresh': auto_refresh, 'uid' : uid, 'active_id': active_id, + 'active_ids': active_ids, + 'active_model': active_model, 'ref' : ref, } context = self.get_context(data_node, rec, eval_context) diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index cd817fa796a..1524d95d922 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -1439,6 +1439,23 @@ def attrgetter(*items): return tuple(resolve_attr(obj, attr) for attr in items) return g +class unquote(str): + """A subclass of str that implements repr() without enclosing quotation marks + or escaping, keeping the original string untouched. The name come from Lisp's unquote. + One of the uses for this is to preserve or insert bare variable names within dicts during eval() + of a dict's repr(). Use with care. + Some examples: + >>> unquote('active_id') + active_id + >>> repr(unquote('active_id')) + active_id + >>> d = {'test': unquote('active_id')} + >>> d + {'test': active_id} + >>> repr(d) + "{'test': active_id}" + """ + def __repr__(self): + return self # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - From 0fb1c7a7992be9d4272695e5b60b81b94a09c7a8 Mon Sep 17 00:00:00 2001 From: Launchpad Translations on behalf of openerp <> Date: Tue, 29 Mar 2011 04:39:26 +0000 Subject: [PATCH 2/3] Launchpad automatic translations update. bzr revid: launchpad_translations_on_behalf_of_openerp-20110329043926-8n5jwee5fkmdi7mt --- debian/po/sq.po | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 debian/po/sq.po diff --git a/debian/po/sq.po b/debian/po/sq.po new file mode 100644 index 00000000000..78c5a241cdc --- /dev/null +++ b/debian/po/sq.po @@ -0,0 +1,39 @@ +# Albanian translation for openobject-server +# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011 +# This file is distributed under the same license as the openobject-server package. +# FIRST AUTHOR , 2011. +# +msgid "" +msgstr "" +"Project-Id-Version: openobject-server\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2009-08-24 22:41+0300\n" +"PO-Revision-Date: 2011-03-28 14:50+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Albanian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2011-03-29 04:39+0000\n" +"X-Generator: Launchpad (build 12559)\n" + +#. Type: string +#. Description +#: ../openerp-server.templates:1001 +msgid "Dedicated system account for the Open ERP server:" +msgstr "" + +#. Type: string +#. Description +#: ../openerp-server.templates:1001 +msgid "" +"The Open ERP server must use a dedicated account for its operation so that " +"the system's security is not compromised by running it with superuser " +"privileges." +msgstr "" + +#. Type: string +#. Description +#: ../openerp-server.templates:1001 +msgid "Please choose that account's username." +msgstr "" From c39f1cca46ccd6b75ab32d071f1322328428f5dd Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 29 Mar 2011 13:38:24 +0200 Subject: [PATCH 3/3] [FIX] orm,ir.model: add eval of domain for relationship fields Without this, it has become impossible to add one2many fields as custom fields, because the domain string is not evaluated bzr revid: odo@openerp.com-20110329113824-5ca5bvp1awzies5u --- openerp/addons/base/ir/ir_model.py | 4 ++-- openerp/osv/orm.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 5ce50370c77..794c419dafd 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -303,10 +303,10 @@ class ir_model_fields(osv.osv): # static table of properties model_props = [ # (our-name, fields.prop, set_fn) - ('field_description', 'string', lambda a: a), + ('field_description', 'string', str), ('required', 'required', bool), ('readonly', 'readonly', bool), - ('domain', '_domain', lambda a: a), + ('domain', '_domain', eval), ('size', 'size', int), ('on_delete', 'ondelete', str), ('translate', 'translate', bool), diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 9ecf547969f..b60d9547869 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -2818,7 +2818,7 @@ class orm(orm_template): 'string': field['field_description'], 'required': bool(field['required']), 'readonly': bool(field['readonly']), - 'domain': field['domain'] or None, + 'domain': eval(field['domain']) if field['domain'] else None, 'size': field['size'], 'ondelete': field['on_delete'], 'translate': (field['translate']),