3
0
Fork 0

[ADD] Option open for One2Many fields

With 'open' option, clicking on a row of a o2m field will open the view for the record in fullscreen rather than in a popup
17.0
Quentin Groulard 2020-01-24 17:07:20 +01:00 committed by manu
parent 9840377d39
commit bf17a7d618
2 changed files with 25 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

@ -13,6 +13,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({
@ -461,6 +462,29 @@ 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",