[FIX] web: use copy of fields when using a kanban model
Since commit [1], properties can be displayed in list views. However, when switching from a kanban view showing the properties to a list view that should be showing the same properties, these are not shown. This happens because the model in the kanban controller currently uses a reference of the fields. When loading the list view, the properties are thus already in the fields, and they are skipped when trying to apply them. This commit solves the issue by working with a copy of the fields in the kanban controller, as the list controller does since commit [1]. [1]: https://github.com/odoo/odoo/commit/70619d0e6a23f955265c99aa6b25924357e46223 Task-3284508 closes odoo/odoo#120128 X-original-commit: 4ccb018ef1d301d2e52fea05b4949d77049be3ca Signed-off-by: David Beguin (dbe) <dbe@odoo.com> Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -84,7 +84,7 @@ export class KanbanController extends Component {
|
||||
return {
|
||||
activeFields: archInfo.activeFields,
|
||||
progressAttributes: archInfo.progressAttributes,
|
||||
fields,
|
||||
fields: { ...fields },
|
||||
resModel,
|
||||
handleField: archInfo.handleField,
|
||||
limit: archInfo.limit || limit,
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
patchWithCleanup,
|
||||
triggerEvent,
|
||||
} from "@web/../tests/helpers/utils";
|
||||
import { createWebClient, doAction } from "@web/../tests/webclient/helpers";
|
||||
import { Many2XAutocomplete } from "@web/views/fields/relational_utils";
|
||||
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
import { SelectCreateDialog } from "@web/views/view_dialogs/select_create_dialog";
|
||||
@@ -1356,6 +1357,44 @@ QUnit.module("Fields", (hooks) => {
|
||||
assert.equal(items.length, 2);
|
||||
});
|
||||
|
||||
/**
|
||||
* Check that the properties are shown when switching view.
|
||||
*/
|
||||
QUnit.test("properties: switch view", async function (assert) {
|
||||
serverData.views = {
|
||||
"partner,false,search": `<search/>`,
|
||||
"partner,99,kanban": `<kanban>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div>
|
||||
<field name="company_id"/> <hr/>
|
||||
<field name="display_name"/> <hr/>
|
||||
<field name="properties" widget="properties"/>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>`,
|
||||
"partner,100,list": `<list limit="1">
|
||||
<field name="display_name"/>
|
||||
<field name="properties"/>
|
||||
</list>`,
|
||||
};
|
||||
const wc = await createWebClient({ serverData });
|
||||
await doAction(wc, {
|
||||
res_model: "partner",
|
||||
type: "ir.actions.act_window",
|
||||
views: [
|
||||
[false, "kanban"],
|
||||
[false, "list"],
|
||||
],
|
||||
});
|
||||
|
||||
await click(target, ".o_switch_view.o_list");
|
||||
assert.ok(target.querySelector(".o_optional_columns_dropdown"),
|
||||
"Properties should be added as optional columns."
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test the behavior of the default value. It should be propagated on the property
|
||||
* value only when we create a new property. If the property already exists, and we
|
||||
|
||||
Reference in New Issue
Block a user