Merge PR #1500 into 12.0

Signed-off-by simahawk
This commit is contained in:
OCA-git-bot
2020-06-18 07:59:40 +00:00
2 changed files with 23 additions and 1 deletions

View File

@@ -37,7 +37,7 @@ in the field's options dict
``open`` *boolean* (Default: ``False``)
Makes many2many_tags buttons that open the linked resource
Makes many2many_tags and one2many rows buttons that open the linked resource
``no_color_picker`` *boolean* (Default: ``False``)

View File

@@ -14,6 +14,7 @@ odoo.define('web_m2x_options.web_m2x_options', function (require) {
var _t = core._t,
FieldMany2ManyTags = relational_fields.FieldMany2ManyTags,
FieldMany2One = relational_fields.FieldMany2One,
FieldOne2Many = relational_fields.FieldOne2Many,
FormFieldMany2ManyTags = relational_fields.FormFieldMany2ManyTags;
var web_m2x_options = rpc.query({
@@ -355,6 +356,27 @@ odoo.define('web_m2x_options.web_m2x_options', function (require) {
},
});
FieldOne2Many.include({
_onOpenRecord: function (ev) {
var self = this;
var open = this.nodeOptions.open;
if (open && self.mode === 'readonly') {
ev.stopPropagation();
var id = ev.data.id;
var res_id = self.record.data[self.name].data.filter(line => line.id === id)[0].res_id;
self._rpc({
model: self.field.relation,
method: 'get_formview_action',
args: [[res_id]],
}).then(function (action) {
return self.do_action(action);
});
} else {
return this._super.apply(this, arguments);
};
},
});
FormFieldMany2ManyTags.include({
events: _.extend({}, FormFieldMany2ManyTags.prototype.events, {
'click .badge': '_onOpenBadge',