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.

38 lines
1.4 KiB

  1. openerp.web_widget_many2many_tags_multi_selection = function(instance, local) {
  2. var _t = instance.web._t;
  3. instance.web.form.CompletionFieldMixin._search_create_popup = function(view, ids, context) {
  4. var self = this;
  5. var pop = new instance.web.form.SelectCreatePopup(this);
  6. var domain = self.build_domain();
  7. if (self.field.type == 'many2many') {
  8. var selected_ids = self.get_search_blacklist();
  9. if (selected_ids.length > 0) {
  10. domain = new instance.web.CompoundDomain(domain, ["!", ["id", "in", selected_ids]]);
  11. }
  12. }
  13. pop.select_element(
  14. self.field.relation,
  15. {
  16. title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string,
  17. initial_ids: ids ? _.map(ids, function(x) {return x[0];}) : undefined,
  18. initial_view: view,
  19. disable_multiple_selection: this.field.type != 'many2many',
  20. },
  21. domain,
  22. new instance.web.CompoundContext(self.build_context(), context || {})
  23. );
  24. pop.on("elements_selected", self, function(element_ids) {
  25. for(var i=0, len=element_ids.length; i<len;i++) {
  26. self.add_id(element_ids[i]);
  27. if (self.field.type != 'many2many') {
  28. break;
  29. }
  30. }
  31. self.focus();
  32. });
  33. };
  34. }