Skip to content

Commit

Permalink
[Fix] web: make sidebar filter generic
Browse files Browse the repository at this point in the history
Adding `res_model` and `res_fields` attributes on a field of
a calendar view adds a filter in the sidebar.
It saves the result as the defined model and should save it
in the defined field.
However `partner_id` has been hardcoded in the rpc call that creates
the record. This breaks genericity, it cannot be used with another
field than `partner_id`.

This commit makes this generic by correctly setting the field name
in the rpc call.
  • Loading branch information
LucasLefevre authored and tivisse committed Jan 18, 2019
1 parent d2b3c9a commit 70c6d3b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/web/static/src/js/views/calendar/calendar_renderer.js
Expand Up @@ -112,11 +112,13 @@ var SidebarFilter = Widget.extend(FieldManagerMixin, {
_onFieldChanged: function (event) {
var self = this;
event.stopPropagation();
var createValues = {'user_id': session.uid};
var value = event.data.changes[this.write_field].id;
createValues[this.write_field] = value;
this._rpc({
model: this.write_model,
method: 'create',
args: [{'user_id': session.uid,'partner_id': value,}],
args: [createValues],
})
.then(function () {
self.trigger_up('changeFilter', {
Expand Down

0 comments on commit 70c6d3b

Please sign in to comment.