[Fix] web: make sidebar filter generic

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.
This commit is contained in:
Lucas Lefèvre
2019-01-18 13:55:34 +01:00
committed by Yannick Tivisse
parent d2b3c9a04b
commit 70c6d3b04c
@@ -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', {