summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/form_common.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-01-03 17:29:20 +0100
committerqsm-odoo <qsm@odoo.com>2017-01-03 18:38:03 +0100
commite3f99885ca789b338a4cb9ab9a154db50dff500d (patch)
tree5661dd542cc429b8b21b0ca2a5c5cf29ecffac08 /addons/web/static/src/js/views/form_common.js
parentbe58a61717e5ea270d280f145de7b7a54bd34745 (diff)
[IMP] web, *: add new Domain and Field selection widgets
* base_action_rule, gamification, mass_mailing 1) Create the independant DomainSelector widget - Allow to build a prefix char domain 2) Replace old FieldCharDomain with a new FieldDomain which uses the new DomainSelector widget 3) Create the independant ModelFieldSelector widget - Allow to build a valid field chain for a specific model (e.g 'partner_id.name' for a 'res.users') - Used by DomainSelector widget --- The DomainSelector widget uses a tree-like representation with user-friendly buttons (ALL/ANY/+/-/...). Any domain can be built, except those containing the "!" (not) operator or some operators like "like", "child_of" (@see DomainSelector). However, if the user enters these in the debug input, the widget can handle them. Note: these widgets had to do unusual stuff the widget API does not allow to handle efficiently right now but it will be adapted to the new widget/field API in a further update. Note2: the widgets also have possibility of other improvements like supporting m2o input instantiation in DomainLeaf, etc. --- This work is an adaptation of the original code made by @pga-odoo.
Diffstat (limited to 'addons/web/static/src/js/views/form_common.js')
-rw-r--r--addons/web/static/src/js/views/form_common.js49
1 files changed, 1 insertions, 48 deletions
diff --git a/addons/web/static/src/js/views/form_common.js b/addons/web/static/src/js/views/form_common.js
index d99c7ed2d2e..273da34f678 100644
--- a/addons/web/static/src/js/views/form_common.js
+++ b/addons/web/static/src/js/views/form_common.js
@@ -945,6 +945,7 @@ var SelectCreateListView = ListView.extend({
this.popup.create_edit_record();
},
select_record: function(index) {
+ if (this.popup.options.readonly) return;
this.popup.on_selected([this.dataset.ids[index]]);
this.popup.close();
},
@@ -1090,53 +1091,6 @@ var SelectCreateDialog = ViewDialog.extend({
on_view_list_loaded: function() {},
});
-var DomainEditorDialog = SelectCreateDialog.extend({
- init: function(parent, options) {
- options = _.defaults(options, {initial_facet: {
- category: _t("Custom Filter"),
- icon: 'fa-star',
- field: {
- get_context: function () { return options.context; },
- get_groupby: function () { return []; },
- get_domain: function () { return options.default_domain; },
- },
- values: [{label: _t("Selected domain"), value: null}],
- }});
-
- this._super(parent, options);
- },
-
- get_domain: function (selected_ids) {
- var group_domain = [];
- var domain;
- if (this.$('.o_list_record_selector input').prop('checked')) {
- if (this.view_list.grouped) {
- group_domain = _.chain(_.values(this.view_list.groups.children))
- .filter(function (child) { return child.records.length; })
- .map(function (c) { return c.datagroup.domain;})
- .value();
- group_domain = _.flatten(group_domain, true);
- group_domain = _.times(group_domain.length - 1, _.constant('|')).concat(group_domain);
- }
- var search_data = this.searchview.build_search_data();
- domain = pyeval.sync_eval_domains_and_contexts({
- domains: search_data.domains,
- contexts: search_data.contexts,
- group_by_seq: search_data.groupbys || []
- }).domain;
- }
- else {
- domain = [["id", "in", selected_ids]];
- }
- return this.dataset.domain.concat(group_domain).concat(domain || []);
- },
-
- on_view_list_loaded: function() {
- this.$('.o_list_record_selector input').prop('checked', true);
- this.$footer.find(".o_selectcreatepopup_search_select").prop('disabled', false);
- },
-});
-
return {
// mixins
FieldManagerMixin: FieldManagerMixin,
@@ -1156,7 +1110,6 @@ return {
ViewDialog: ViewDialog,
FormViewDialog: FormViewDialog,
SelectCreateDialog: SelectCreateDialog,
- DomainEditorDialog: DomainEditorDialog,
};
});