").addClass('fa fa-arrow-right'));
+ this.domainSelector = new DomainSelector(this, this.model, domain, {
+ readonly: this.get("effective_readonly"),
+ fs_filters: this.options.fs_filters,
+ debugMode: session.debug,
});
-
- if(this.debug) {
- this.$('.o_debug_input').val(this.get('value'));
- }
- } else {
- this.$('.o_form_input').val('');
- this.$('.o_count').text(_t('No selected record'));
- var $arrow = this.$('button span').detach();
- this.$('button').text(_t('Select records ')).append($("
").addClass('fa fa-arrow-right'));
+ this.domainSelector.prependTo(this.$el);
}
- },
- on_click: function(event) {
- event.preventDefault();
- var self = this;
- var dialog = new common.DomainEditorDialog(this, {
- res_model: this.options.model || this.field_manager.get_field_value(this.options.model_field),
- default_domain: this.get('value'),
- title: this.get('effective_readonly') ? _t('Selected records') : _t('Select records...'),
- readonly: this.get('effective_readonly'),
- disable_multiple_selection: this.get('effective_readonly'),
- no_create: this.get('effective_readonly'),
- on_selected: function(selected_ids) {
- if (!self.get('effective_readonly')) {
- self.set_value(dialog.get_domain(selected_ids));
- }
- }
+ // Show number of selected records
+ new Model(this.model).call("search_count", [domain], {
+ context: this.build_context(),
+ }).then((function (data) {
+ this.valid = true;
+ return data;
+ }).bind(this), (function (error, e) {
+ e.preventDefault();
+ this.valid = false;
+ }).bind(this)).always((function (data) {
+ this.$recordsCountDisplay.text(data || 0);
+ this.$showSelectionButton.toggleClass("hidden", !this.valid);
+ this.$errorMessage.toggleClass("hidden", this.valid);
+ }).bind(this));
+ },
+ is_syntax_valid: function() {
+ return this.field_manager.get("actual_mode") === "view" || this.valid;
+ },
+ _showSelection: function() {
+ return new common.SelectCreateDialog(this, {
+ title: _t("Selected records"),
+ res_model: this.model,
+ domain: this.get("value"),
+ no_create: true,
+ readonly: true,
+ disable_multiple_selection: true,
}).open();
},
});
@@ -1315,7 +1341,7 @@ var FieldStatus = common.AbstractField.extend({
render_value: function() {
var self = this;
var content = QWeb.render("FieldStatus.content", {
- 'widget': self,
+ 'widget': self,
'value_folded': _.find(self.selection.folded, function(i){return i[0] === self.get('value');})
});
self.$el.html(content);
@@ -1506,7 +1532,7 @@ var FieldMonetary = FieldFloat.extend({
/**
This widget is intended to be used on stat button numeric fields. It will display
- the value many2many and one2many. It is a read-only field that will
+ the value many2many and one2many. It is a read-only field that will
display a simple string "