[FIX] web: kanban: allow to specify custom Compiler

This commit allows to specify a custom Compiler to be used by the
KanbanRecord of a custom Kanban view (js_class). This is necessary
for the social kanban views. Something similar is already done in
the Form view.

closes odoo/odoo#108221

Related: odoo/enterprise#35065
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2022-12-19 16:49:03 +01:00
parent 7095310672
commit ea7ef13b0f
6 changed files with 10 additions and 2 deletions
@@ -132,6 +132,7 @@ KanbanController.props = {
forceGlobalClick: { type: Boolean, optional: true },
onSelectionChanged: { type: Function, optional: true },
showButtons: { type: Boolean, optional: true },
Compiler: { type: Function, optional: true }, // optional in stable for backward compatibility
Model: Function,
Renderer: Function,
buttonTemplate: String,
@@ -10,6 +10,7 @@
<t t-component="props.Renderer"
list="model.root"
archInfo="props.archInfo"
Compiler="props.Compiler"
readonly="true"
forceGlobalClick="props.forceGlobalClick"
openRecord.bind="openRecord"
@@ -163,7 +163,7 @@ export class KanbanRecord extends Component {
const { archInfo, Compiler, templates } = this.props;
const { arch } = archInfo;
const ViewCompiler = Compiler || KanbanCompiler;
const ViewCompiler = Compiler || this.constructor.Compiler;
this.templates = useViewCompiler(ViewCompiler, arch, templates);
@@ -356,7 +356,6 @@ export class KanbanRecord extends Component {
};
}
}
KanbanRecord.components = {
Dropdown,
DropdownItem,
@@ -383,5 +382,6 @@ KanbanRecord.props = [
"record",
"templates",
];
KanbanRecord.Compiler = KanbanCompiler;
KanbanRecord.KANBAN_BOX_ATTRIBUTE = KANBAN_BOX_ATTRIBUTE;
KanbanRecord.template = "web.KanbanRecord";
@@ -606,6 +606,7 @@ export class KanbanRenderer extends Component {
KanbanRenderer.props = [
"archInfo",
"Compiler?", // optional in stable for backward compatibility
"list",
"openRecord",
"readonly",
@@ -97,6 +97,7 @@
<t t-else="">
<KanbanRecord
archInfo="props.archInfo"
Compiler="props.Compiler"
canResequence="canResequenceRecords"
forceGlobalClick="props.forceGlobalClick"
group="group"
@@ -124,6 +125,7 @@
<t t-else="">
<KanbanRecord
archInfo="props.archInfo"
Compiler="props.Compiler"
canResequence="canResequenceRecords"
forceGlobalClick="props.forceGlobalClick"
list="props.list"
@@ -1,6 +1,7 @@
/** @odoo-module **/
import { KanbanArchParser } from "./kanban_arch_parser";
import { KanbanCompiler } from "./kanban_compiler";
import { KanbanController } from "./kanban_controller";
import { KanbanModel } from "./kanban_model";
import { KanbanRenderer } from "./kanban_renderer";
@@ -18,6 +19,7 @@ export const kanbanView = {
Controller: KanbanController,
Model: KanbanModel,
Renderer: KanbanRenderer,
Compiler: KanbanCompiler,
buttonTemplate: "web.KanbanView.Buttons",
@@ -30,6 +32,7 @@ export const kanbanView = {
return {
...genericProps,
// Compiler: view.Compiler, // don't pass it automatically in stable, for backward compat
Model: view.Model,
Renderer: view.Renderer,
buttonTemplate: view.buttonTemplate,