summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-01-04 16:26:57 +0100
committerqsm-odoo <qsm@odoo.com>2017-01-06 16:03:09 +0100
commitb8eb821f1353700dac26383d5d4950232305c852 (patch)
treefa58cd39f33bc02186b3ae4862fa980c87d22f1b /addons/web/static/src/js/framework
parent95d823d9db5351d0a90ea4edea8410fc77d6641b (diff)
[IMP] web: allow DomainSelector widget to be instanciated with a string
Before this commit, the DomainSelector had to be instanciated with an array-typed value which forced the user to use (and import) the pyeval module. Now, the conversion to array is done in the DomainSelector. This commit introduces a web.domainUtils module allowing to do the convertion array -> string and string -> array of a domain.
Diffstat (limited to 'addons/web/static/src/js/framework')
-rw-r--r--addons/web/static/src/js/framework/domain_utils.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/addons/web/static/src/js/framework/domain_utils.js b/addons/web/static/src/js/framework/domain_utils.js
new file mode 100644
index 00000000000..8cefb7cabbe
--- /dev/null
+++ b/addons/web/static/src/js/framework/domain_utils.js
@@ -0,0 +1,19 @@
+odoo.define("web.domainUtils", function (require) {
+"use strict";
+
+var pyeval = require("web.pyeval");
+
+function domainToString(domain) {
+ if (_.isString(domain)) return domain;
+ return JSON.stringify(domain || []).replace(/false/g, "False").replace(/true/g, "True");
+}
+function stringToDomain(domain) {
+ if (!_.isString(domain)) return domain;
+ return pyeval.eval("domain", domain || "[]");
+}
+
+return {
+ domainToString: domainToString,
+ stringToDomain: stringToDomain,
+};
+});