Skip to content

Commit

Permalink
[FIX] linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierrick Brun committed May 24, 2023
1 parent 47b313d commit 49ad90a
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 147 deletions.
9 changes: 3 additions & 6 deletions open_in_new_tab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ Right click on the man2many field then open the record in new browser tab

![Open many2many field in new tab](https://ngasturi.id/wp-content/uploads/2021/01/open_many2many_in_new_tab.png)



Right click on the man2one field then open the record in new browser tab

![Open many2one field in new tab](https://ngasturi.id/wp-content/uploads/2021/01/open_many2one_in_new_tab.png)



This module will add a new icon on the left side of list view, right click on that icon to open list view in new browser tab or click on other area to open in the normal way
This module will add a new icon on the left side of list view, right click on that icon
to open list view in new browser tab or click on other area to open in the normal way

![Open list view in new tab](https://ngasturi.id/wp-content/uploads/2021/01/open_list_view_in_new_tab.png)

This module is tested on odoo version 13 and 14
This module is tested on odoo version 13 and 14
23 changes: 7 additions & 16 deletions open_in_new_tab/__manifest__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
{
"name": "Open odoo record in new tab",
"author": "Ngasturi",
"author": "Ngasturi", # pylint: disable=manifest-required-author
"version": "14.0.1.0.1",
"category": "Web",
"website": "https://ngasturi.id",
"website": "https://github.com/akretion/ak-odoo-incubator", # https://ngasturi.id
"summary": "",
"description": """
""",
"depends": [
"web"
],
"data": [
"views/assets.xml"
],
"qweb": [
"static/src/xml/template.xml"
],
"license": 'LGPL-3',
"installable": True
"depends": ["web"],
"data": ["views/assets.xml"],
"qweb": ["static/src/xml/template.xml"],
"license": "LGPL-3",
"installable": True,
}
23 changes: 8 additions & 15 deletions open_in_new_tab/static/src/js/many2many.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
odoo.define('open_in_new_tab.many2many', function (require) {
"use strict";

var relational_fields = require('web.relational_fields');
var core = require('web.core');

var _t = core._t;
var _lt = core._lt;
var qweb = core.qweb;
odoo.define("open_in_new_tab.many2many", function (require) {
"use strict";

var relational_fields = require("web.relational_fields");

relational_fields.FieldMany2ManyTags.include({
_getRenderTagsContext: function () {
var elements = this.value ? _.pluck(this.value.data, 'data') : [];
var elements = this.value ? _.pluck(this.value.data, "data") : [];

var queryString = window.location.hash.substring(1);
var urlParams = new URLSearchParams(queryString);
var menuId = urlParams.get('menu_id') || '';
var menuId = urlParams.get("menu_id") || "";

return {
colorField: this.colorField,
elements: elements,
hasDropdown: this.hasDropdown,
readonly: this.mode === "readonly",
model: this.field.relation,
menuId: menuId
menuId: menuId,
};
},
});

});
});
59 changes: 36 additions & 23 deletions open_in_new_tab/static/src/js/many2one.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
odoo.define('open_in_new_tab.many2one', function (require) {
"use strict";

var relational_fields = require('web.relational_fields');
var core = require('web.core');

var _t = core._t;
var _lt = core._lt;
var qweb = core.qweb;
odoo.define("open_in_new_tab.many2one", function (require) {
"use strict";

var relational_fields = require("web.relational_fields");

relational_fields.FieldMany2One.include({
_renderReadonly: function () {
var escapedValue = _.escape((this.m2o_value || "").trim());
var value = escapedValue.split('\n').map(function (line) {
return '<span>' + line + '</span>';
}).join('<br/>');
var value = escapedValue
.split("\n")
.map(function (line) {
return "<span>" + line + "</span>";
})
.join("<br/>");
this.$el.html(value);
if (!this.noOpen && this.value) {
var queryString = window.location.hash.substring(1);
var urlParams = new URLSearchParams(queryString);
var menuId = urlParams.get('menu_id') || '';

this.$el.attr('href', _.str.sprintf('#id=%s&model=%s&menu_id=%s', this.value.res_id, this.field.relation, menuId));
this.$el.addClass('o_form_uri');
var menuId = urlParams.get("menu_id") || "";

this.$el.attr(
"href",
_.str.sprintf(
"#id=%s&model=%s&menu_id=%s",
this.value.res_id,
this.field.relation,
menuId
)
);
this.$el.addClass("o_form_uri");
}
},

Expand All @@ -32,10 +37,19 @@ odoo.define('open_in_new_tab.many2one', function (require) {
if (!this.noOpen && this.value) {
var queryString = window.location.hash.substring(1);
var urlParams = new URLSearchParams(queryString);
var menuId = urlParams.get('menu_id') || '';

this.$el.find('.o_external_button').attr('href', _.str.sprintf('#id=%s&model=%s&menu_id=%s', this.value.res_id, this.field.relation, menuId));

var menuId = urlParams.get("menu_id") || "";

this.$el
.find(".o_external_button")
.attr(
"href",
_.str.sprintf(
"#id=%s&model=%s&menu_id=%s",
this.value.res_id,
this.field.relation,
menuId
)
);
}
},

Expand All @@ -44,7 +58,6 @@ odoo.define('open_in_new_tab.many2one', function (require) {
ev.stopPropagation();

this._super.apply(this, arguments);
}
},
});

});
});
Loading

0 comments on commit 49ad90a

Please sign in to comment.