[FIX] web: compile a button with id

Before this commit, button ids (if any) were absent from the templates
generated by a view compiler.

Part-of: odoo/odoo#95413
This commit is contained in:
Mathieu Duckerts-Antoine
2022-07-06 17:10:28 +02:00
parent 825fa5b9f0
commit 3d6f0c200d
4 changed files with 23 additions and 1 deletions
@@ -113,6 +113,7 @@ export class ViewButton extends Component {
}
ViewButton.template = "views.ViewButton";
ViewButton.props = [
"id?",
"tag?",
"record?",
"className?",
@@ -3,6 +3,7 @@
<t t-name="views.ViewButton" owl="1">
<t t-tag="props.tag"
t-att-id="props.id"
t-att-class="getClassName()"
t-att-disabled="disabled"
t-att-name="props.clickParams.name"
+1 -1
View File
@@ -34,7 +34,7 @@ const BUTTON_CLICK_PARAMS = [
// just override compileButton in kanban compiler to add the debounce?
"debounce",
];
const BUTTON_STRING_PROPS = ["string", "size", "title", "icon"];
const BUTTON_STRING_PROPS = ["string", "size", "title", "icon", "id"];
const INTERP_REGEXP = /(\{\{|#\{)(.*?)(\}{1,2})/g;
/**
@@ -271,4 +271,24 @@ QUnit.module("Form Renderer", (hooks) => {
resId: 1,
});
});
QUnit.test("compile a button with id", async (assert) => {
serverData.views = {
"partner,1,form": /*xml*/ `
<form>
<header>
<button id="action_button" string="ActionButton"/>
</header>
</form>`,
};
await makeView({
serverData,
resModel: "partner",
type: "form",
resId: 1,
});
assert.containsOnce(target, "button[id=action_button]");
});
});