summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2012-02-08 13:43:09 +0100
committerXavier Morel <xmo@openerp.com>2012-02-08 13:43:09 +0100
commitff570e8d233eef4445105ed4700eba3da1942c1c (patch)
tree5a81b8222e713a62e8d71f4f8c92dfa5f0a91246 /addons/web/static/src/js
parent69fdc31167e3dc0396015a6190ca1636d784e88a (diff)
[IMP] have registries remain linked so alterations to a parent registry alters its clone as well (if keys are not overwritten in the child)
bzr revid: xmo@openerp.com-20120208124309-iho04vgae2nz6xix
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/core.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js
index 6bac3fa39e6..4495334aa23 100644
--- a/addons/web/static/src/js/core.js
+++ b/addons/web/static/src/js/core.js
@@ -254,6 +254,7 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry
* @param {Object} mapping a mapping of keys to object-paths
*/
init: function (mapping) {
+ this.parent = null;
this.map = mapping || {};
},
/**
@@ -269,6 +270,9 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry
get_object: function (key, silent_error) {
var path_string = this.map[key];
if (path_string === undefined) {
+ if (this.parent) {
+ return this.parent.get_object(key, silent_error);
+ }
if (silent_error) { return void 'nooo'; }
throw new openerp.web.KeyNotFound(key);
}
@@ -327,8 +331,9 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry
* @param {Object} [mapping={}] a mapping of keys to object-paths
*/
clone: function (mapping) {
- return new openerp.web.Registry(
- _.extend({}, this.map, mapping || {}));
+ var child = new openerp.web.Registry(mapping);
+ child.parent = this;
+ return child;
}
});