forked from Techsystech/web
[MIG] web_tree_many2one_clickable: Migration to 15.0
parent
a26e399cbd
commit
7176c70877
|
@ -7,7 +7,7 @@
|
|||
{
|
||||
"name": "Clickable many2one fields for tree views",
|
||||
"summary": "Open the linked resource when clicking on their name",
|
||||
"version": "14.0.1.0.2",
|
||||
"version": "15.0.1.0.0",
|
||||
"category": "Hidden",
|
||||
"website": "https://github.com/OCA/web",
|
||||
"author": "Therp BV, "
|
||||
|
@ -17,5 +17,13 @@
|
|||
"license": "AGPL-3",
|
||||
"installable": True,
|
||||
"depends": ["web"],
|
||||
"data": ["views/assets.xml"],
|
||||
"data": [],
|
||||
"assets": {
|
||||
"web.assets_backend": [
|
||||
"web_tree_many2one_clickable/static/src/js/*.js",
|
||||
],
|
||||
"web.assets_common": [
|
||||
"web_tree_many2one_clickable/static/src/css/web_tree_many2one_clickable.scss",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
td.o_many2one_cell {
|
||||
a {
|
||||
margin-left: 0.5em;
|
||||
visibility: hidden;
|
||||
}
|
||||
a {
|
||||
margin-left: 0.5em;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
&:hover a {
|
||||
visibility: visible;
|
||||
}
|
||||
&:hover a {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,64 +7,62 @@
|
|||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
|
||||
odoo.define("web_tree_many2one_clickable.many2one_clickable", function (require) {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
var ListRenderer = require("web.ListRenderer");
|
||||
var ListFieldMany2One = require("web.relational_fields").ListFieldMany2One;
|
||||
var ListRenderer = require("web.ListRenderer");
|
||||
var ListFieldMany2One = require("web.relational_fields").ListFieldMany2One;
|
||||
|
||||
ListRenderer.include({
|
||||
_renderBodyCell: function (record, node, colIndex, options) {
|
||||
if (
|
||||
!node.attrs.widget &&
|
||||
node.attrs.name &&
|
||||
this.state.fields[node.attrs.name] &&
|
||||
this.state.fields[node.attrs.name].type === "many2one"
|
||||
) {
|
||||
// No explicit widget provided on a many2one field,
|
||||
// force `many2one` widget
|
||||
node.attrs.widget = "many2one";
|
||||
}
|
||||
return this._super(record, node, colIndex, options);
|
||||
},
|
||||
});
|
||||
ListRenderer.include({
|
||||
_renderBodyCell: function (record, node, colIndex, options) {
|
||||
if (
|
||||
!node.attrs.widget &&
|
||||
node.attrs.name &&
|
||||
this.state.fields[node.attrs.name] &&
|
||||
this.state.fields[node.attrs.name].type === "many2one"
|
||||
) {
|
||||
// No explicit widget provided on a many2one field,
|
||||
// force `many2one` widget
|
||||
node.attrs.widget = "many2one";
|
||||
}
|
||||
return this._super(record, node, colIndex, options);
|
||||
},
|
||||
});
|
||||
|
||||
ListFieldMany2One.include({
|
||||
_renderReadonly: function () {
|
||||
this._super.apply(this, arguments);
|
||||
var self = this;
|
||||
ListFieldMany2One.include({
|
||||
_renderReadonly: function () {
|
||||
this._super.apply(this, arguments);
|
||||
var self = this;
|
||||
|
||||
if (!this.noOpen && this.value) {
|
||||
// Replace '<a>' element
|
||||
this.$el.removeClass("o_form_uri");
|
||||
this.$el = $("<span/>", {
|
||||
html: this.$el.html(),
|
||||
class: this.$el.attr("class") + " o_field_text",
|
||||
name: this.$el.attr("name"),
|
||||
});
|
||||
if (!this.noOpen && this.value) {
|
||||
// Replace '<a>' element
|
||||
this.$el.removeClass("o_form_uri");
|
||||
this.$el = $("<span/>", {
|
||||
html: this.$el.html(),
|
||||
class: this.$el.attr("class") + " o_field_text",
|
||||
name: this.$el.attr("name"),
|
||||
});
|
||||
|
||||
// Append button
|
||||
var $a = $("<a/>", {
|
||||
href: "#",
|
||||
class:
|
||||
"o_form_uri btn btn-sm btn-secondary" +
|
||||
" fa fa-angle-double-right",
|
||||
}).on("click", function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
// Append button
|
||||
var $a = $("<a/>", {
|
||||
href: "#",
|
||||
class: "o_form_uri btn btn-sm btn-secondary fa fa-angle-double-right",
|
||||
}).on("click", function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
self.do_action({
|
||||
type: "ir.actions.act_window",
|
||||
res_model: self.field.relation,
|
||||
res_id: self.value.res_id,
|
||||
views: [[false, "form"]],
|
||||
target: "target",
|
||||
context: self.record.getContext({
|
||||
additionalContext: self.attrs.context || {},
|
||||
}),
|
||||
});
|
||||
});
|
||||
this.$el.append($a);
|
||||
}
|
||||
},
|
||||
});
|
||||
self.do_action({
|
||||
type: "ir.actions.act_window",
|
||||
res_model: self.field.relation,
|
||||
res_id: self.value.res_id,
|
||||
views: [[false, "form"]],
|
||||
target: "target",
|
||||
context: self.record.getContext({
|
||||
additionalContext: self.attrs.context || {},
|
||||
}),
|
||||
});
|
||||
});
|
||||
this.$el.append($a);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
Copyright 2019 Alexandre Díaz <alexandre.diaz@tecnativa.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="web_tree_many2one_clickable assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/web_tree_many2one_clickable/static/src/css/web_tree_many2one_clickable.scss"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_tree_many2one_clickable/static/src/js/web_tree_many2one_clickable.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
Loading…
Reference in New Issue