Browse Source

[FIX] web_edit_user_filter: Custom filters

pull/1224/head
tarteo 6 years ago
committed by Dennis Sluijk
parent
commit
f896370204
  1. 2
      web_edit_user_filter/__manifest__.py
  2. 19
      web_edit_user_filter/static/src/js/backend.js
  3. 2
      web_edit_user_filter/static/src/xml/backend.xml

2
web_edit_user_filter/__manifest__.py

@ -4,7 +4,7 @@
{
'name': 'Edit User Filters',
'category': 'Extra Tools',
'version': '12.0.1.0.0',
'version': '12.0.1.0.1',
'development_status': 'Production/Stable',
'author': 'Onestein,Odoo Community Association (OCA)',
'license': 'AGPL-3',

19
web_edit_user_filter/static/src/js/backend.js

@ -100,11 +100,13 @@ odoo.define('web_edit_user_filter', function (require) {
self.trigger_up('menu_item_toggled', eventData);
});
} else if (segment.cat === 'filterCategory') {
var new_filters = [];
_.each(segment.values, function (value) {
if (value.attrs.name) {
var filterDomain = _.find(
self.searchview.filtersMapping,
function (mapping) {
return mapping.filter.attrs.domain === value.attrs.domain;
return mapping.filter.attrs.name === value.attrs.name;
}
);
var eventData = {
@ -113,8 +115,20 @@ odoo.define('web_edit_user_filter', function (require) {
isActive: true,
groupId: filterDomain.groupId,
};
self.trigger_up('menu_item_toggled', eventData);
} else {
new_filters.push({
groupId: null,
filter: {
tag: 'filter',
attrs: value.attrs
},
itemId: _.uniqueId('__filter__')
});
}
});
self.trigger_up('new_filters', new_filters);
} else {
var search_widget = _.find(
self.searchview.search_fields, function (f) {
@ -145,7 +159,7 @@ odoo.define('web_edit_user_filter', function (require) {
_removeValue: function (model, value) {
var toRemove = model.values.filter(function (v) {
if (typeof v.attributes.value === 'object') {
return v.attributes.value.attrs.name === value;
return v.attributes.value.attrs.domain === value;
}
return v.attributes.value.toString() === value;
@ -162,7 +176,6 @@ odoo.define('web_edit_user_filter', function (require) {
*/
_renderPopover: function ($facet, model) {
var self = this;
var $content = $(qweb.render('web_edit_user_filter.Popover', {
values: model.get('values'),
}));

2
web_edit_user_filter/static/src/xml/backend.xml

@ -8,7 +8,7 @@
<div class="list-group">
<t t-foreach="values" t-as="value">
<a class="list-group-item list-group-item-action"
t-attf-data-value="#{typeof value.value === 'object' ? value.value.attrs.name : value.value}">
t-attf-data-value="#{typeof value.value === 'object' ? value.value.attrs.domain : value.value}">
<span>
<t t-esc="value.label"/>
</span>

Loading…
Cancel
Save