[IMP] runbot: add a widget to go to runbot frontend

With this commit, a custom widget is added to go to the reunbot frontend
from a Char field. This allows to go from the bundle backend page to the
bundle frontend page wich is more useful in some situations.

e.g.: when creating a custom trigger with the wizard, this allows to
test the trigger with 2 clicks.
This commit is contained in:
Christophe Monniez 2023-05-31 16:14:39 +02:00 committed by xdo
parent e445ed27db
commit 86616ba88e
2 changed files with 25 additions and 2 deletions

View File

@ -36,6 +36,29 @@ var FieldJson = basic_fields.FieldChar.extend({
registry.add('jsonb', FieldJson)
var FieldCharFrontendUrl = basic_fields.FieldChar.extend({
quickEditExclusion: [
'.fa-external-link',
],
init() {
this._super.apply(this, arguments);
if (this.model.startsWith('runbot.')) {
this.route = '/runbot/' + this.model.split('.')[1] + '/' + this.res_id;
} else {
this.route = false;
}
},
_renderReadonly: function() {
this._super.apply(this, arguments);
var link= '';
if (this.route) {
link = ' <a href="'+this.route+'" target="_blank"><i class="external_link fa fa-fw o_button_icon fa-external-link "/></a>';
this.$el.html('<span>' + this.$el.html() + link + '<span>');
}
}
});
registry.add('char_frontend_url', FieldCharFrontendUrl)
var FrontendUrl = relational_fields.FieldMany2One.extend({
isQuickEditable: false,

View File

@ -39,7 +39,7 @@
<div class="oe_button_box" name="button_box">
</div>
<group>
<field name="name"/>
<field name="name" widget="char_frontend_url"/>
<field name="project_id"/>
<field name="sticky" readonly="0"/>
<field name="to_upgrade" readonly="0"/>
@ -124,7 +124,7 @@
<field name="arch" type="xml">
<tree string="Bundle">
<field name="project_id"/>
<field name="name"/>
<field name="name" widget="char_frontend_url"/>
<field name="version_number"/>
<field name="is_base"/>
<field name="sticky"/>