You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.7 KiB

  1. odoo.define('web_widget_many2many_tags_multi_selection.multiple_tags', function (require) {
  2. "use strict";
  3. var rel_fields = require('web.relational_fields');
  4. var dialogs = require('web.view_dialogs');
  5. var core = require('web.core');
  6. var _t = core._t;
  7. rel_fields.FieldMany2One.include({
  8. _searchCreatePopup: function(view, ids, context) {
  9. var self = this;
  10. // Don't include already selected instances in the search domain
  11. var domain = self.record.getDomain({fieldName: self.name});
  12. if (self.field.type === 'many2many') {
  13. var selected_ids = self._getSearchBlacklist();
  14. if (selected_ids.length > 0) {
  15. domain.push(['id', 'not in', selected_ids]);
  16. }
  17. }
  18. new dialogs.SelectCreateDialog(self, _.extend({}, self.nodeOptions, {
  19. res_model: self.field.relation,
  20. domain: domain,
  21. context: _.extend({}, self.record.getContext(self.recordParams), context || {}),
  22. title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + self.string,
  23. initial_ids: ids ? _.map(ids, function(x) {return x[0];}) : undefined,
  24. initial_view: view,
  25. disable_multiple_selection: self.field.type !== 'many2many',
  26. on_selected: function(records) {
  27. if (self.field.type !== 'many2many') {
  28. self.reinitialize(records[0]);
  29. } else {
  30. self.reinitialize(records);
  31. }
  32. self.activate();
  33. }
  34. })).open();
  35. },
  36. });
  37. });