[FIX] account: section_and_note fields not working
This seems to be caused by changes in odoo/odoo#97984 The tests didn't seem to be executing since they had legacy dependencies closes odoo/odoo#100025 Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -109,8 +109,7 @@ You could use this simplified accounting in case you work with an (external) acc
|
||||
'account/static/tests/tours/**/*',
|
||||
],
|
||||
'web.qunit_suite_tests': [
|
||||
('after', 'web/static/tests/legacy/views/kanban_tests.js', 'account/static/tests/account_payment_field_tests.js'),
|
||||
('after', 'web/static/tests/legacy/views/kanban_tests.js', 'account/static/tests/section_and_note_tests.js'),
|
||||
'account/static/tests/*.js',
|
||||
],
|
||||
'web.assets_qweb': [
|
||||
'account/static/src/xml/**/*',
|
||||
|
||||
+24
-17
@@ -17,6 +17,7 @@ export class SectionAndNoteListRenderer extends ListRenderer {
|
||||
*/
|
||||
setup() {
|
||||
super.setup();
|
||||
this.titleField = "name";
|
||||
useEffect(
|
||||
() => this.focusToName(this.props.list.editedRecord),
|
||||
() => [this.props.list.editedRecord]
|
||||
@@ -25,7 +26,7 @@ export class SectionAndNoteListRenderer extends ListRenderer {
|
||||
|
||||
focusToName(editRec) {
|
||||
if (editRec && editRec.isVirtual && this.isSectionOrNote(editRec)) {
|
||||
const col = this.state.columns.find((c) => c.name === "name");
|
||||
const col = this.state.columns.find((c) => c.name === this.titleField);
|
||||
this.focusCell(col, null);
|
||||
}
|
||||
}
|
||||
@@ -42,32 +43,38 @@ export class SectionAndNoteListRenderer extends ListRenderer {
|
||||
|
||||
getCellClass(column, record) {
|
||||
const classNames = super.getCellClass(column, record);
|
||||
if (this.isSectionOrNote(record) && column.widget !== "handle" && column.name !== "name") {
|
||||
if (this.isSectionOrNote(record) && column.widget !== "handle" && column.name !== this.titleField) {
|
||||
return `${classNames} o_hidden`;
|
||||
}
|
||||
return classNames;
|
||||
}
|
||||
|
||||
getCellColspan(column) {
|
||||
if (!this.isSectionOrNote() || column.widget === "handle") {
|
||||
return 1;
|
||||
getColumns(record) {
|
||||
const columns = super.getColumns(record);
|
||||
if (this.isSectionOrNote(record)) {
|
||||
return this.getSectionColumns(columns);
|
||||
}
|
||||
let nbrColumns = this.withHandleColumn ? this.state.columns.length + 1 : this.state.columns.length;
|
||||
let withTrashColumn = this.props.activeActions && (this.props.activeActions.canDelete || this.props.activeActions.canUnlink || 0);
|
||||
return nbrColumns - this.withHandleColumn - withTrashColumn;
|
||||
return columns;
|
||||
}
|
||||
|
||||
getSectionColumns(columns) {
|
||||
const sectionCols = columns.filter((col) => col.widget === "handle" || col.type === "field" && col.name === this.titleField);
|
||||
return sectionCols.map((col) => {
|
||||
if (col.name === this.titleField) {
|
||||
return { ...col, colspan: columns.length - sectionCols.length + 1 };
|
||||
} else {
|
||||
return { ...col };
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SectionAndNoteListRenderer.template = "account.sectionAndNoteListRenderer";
|
||||
SectionAndNoteListRenderer.recordRowTemplate = "account.SectionAndNoteListRenderer.RecordRow";
|
||||
|
||||
export class SectionAndNoteFieldOne2Many extends X2ManyField {
|
||||
setup() {
|
||||
super.setup();
|
||||
if (this.viewMode === 'list') {
|
||||
this.Renderer = SectionAndNoteListRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
export class SectionAndNoteFieldOne2Many extends X2ManyField {}
|
||||
SectionAndNoteFieldOne2Many.components = {
|
||||
...X2ManyField.components,
|
||||
ListRenderer: SectionAndNoteListRenderer,
|
||||
};
|
||||
|
||||
export class SectionAndNoteText extends Component {
|
||||
get componentToUse() {
|
||||
|
||||
+1
-7
@@ -2,13 +2,7 @@
|
||||
<templates>
|
||||
<t t-name="account.sectionAndNoteListRenderer" t-inherit="web.ListRenderer" t-inherit-mode="primary" owl="1">
|
||||
<xpath expr="//table" position="attributes">
|
||||
<attribute name="t-att-class">'o_section_and_note_list_view'</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<t t-name="account.SectionAndNoteListRenderer.RecordRow" t-inherit="web.ListRenderer.RecordRow" t-inherit-mode="primary" owl="1">
|
||||
<xpath expr="//td[@class='o_data_cell']" position="attributes">
|
||||
<attribute name="t-att-colspan">getCellColspan(column)</attribute>
|
||||
<attribute name="class" position="add" separator=" ">o_section_and_note_list_view</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user