[FIX] web: correct type of defaultPage prop
Steps to reproduce: - go to "Link Tracker" app; - go to "Campaigns" tab (UTMs); - create a new campaign; - leave and return in this record. Issue: A traceback appears. Error message: `Invalid props for component 'Notebook': 'defaultPage' is not a string` Cause: The `defaultPage` prop must be a string. When the record is new, it will be `undefined`, so it will pass props validation because this prop is optional. But when we try to calculate it and it does not return a value, the `defaultPage` is null. The variable is therefore declared but it is empty (and therefore not a string). `null` value does not pass the props validation test. The problem appears in the "Campaigns" tab because there is a notebook without content. Solution: Test if it is possible to have a value. If not, set the `defaultPage` prop to be `undefined`. opw-3109327 closes odoo/odoo#109533 X-original-commit: 402b1a822c3983af33aa1d3a3c7e93d8836c60d8 Signed-off-by: Dardenne Florent (dafl) <dafl@odoo.com>
This commit is contained in:
@@ -187,7 +187,9 @@ export class FormController extends Component {
|
||||
this.fieldsToTranslate = useState(fieldsToTranslate || {});
|
||||
const activeNotebookPages = { ...state.activeNotebookPages };
|
||||
this.onNotebookPageChange = (notebookId, page) => {
|
||||
activeNotebookPages[notebookId] = page;
|
||||
if (page) {
|
||||
activeNotebookPages[notebookId] = page;
|
||||
}
|
||||
};
|
||||
|
||||
useSetupView({
|
||||
|
||||
@@ -12976,4 +12976,41 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.strictEqual(target.querySelector(".o_form_nosheet").innerHTML, "<div></div>");
|
||||
assert.verifySteps(["warn", "warn", "warn", "warn"]);
|
||||
});
|
||||
|
||||
QUnit.test("reload form view with an empty notebook", async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
serverData.views = {
|
||||
"partner,false,form": `
|
||||
<form>
|
||||
<sheet>
|
||||
<notebook>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>`,
|
||||
"partner,false,list": '<tree><field name="foo"/></tree>',
|
||||
"partner,false,search": "<search></search>",
|
||||
};
|
||||
|
||||
serverData.actions = {
|
||||
1: {
|
||||
id: 1,
|
||||
name: "Partner",
|
||||
res_model: "partner",
|
||||
type: "ir.actions.act_window",
|
||||
views: [
|
||||
[false, "list"],
|
||||
[false, "form"],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const target = getFixture();
|
||||
const webClient = await createWebClient({ serverData });
|
||||
await doAction(webClient, 1);
|
||||
await click(target.querySelector(".o_data_row .o_data_cell"));
|
||||
await click(target.querySelector(".o_back_button"));
|
||||
await click(target.querySelector(".o_data_row .o_data_cell"));
|
||||
assert.containsOnce(target, ".o_form_view");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user