From dee24513052d8eed45ed6f254077f82b93c503fe Mon Sep 17 00:00:00 2001 From: FernandoRomera Date: Fri, 26 Jul 2024 06:16:42 +0200 Subject: [PATCH] [MIG] spreadsheet_oca: Migration to 17.0 --- .copier-answers.yml | 2 +- .eslintrc.yml | 188 ++++++++++++++++++ .gitignore | 9 + .pre-commit-config.yaml | 2 +- spreadsheet_oca/__manifest__.py | 2 +- spreadsheet_oca/models/ir_websocket.py | 3 +- .../spreadsheet_spreadsheet_import_mode.py | 2 +- .../src/spreadsheet/bundle/chart_panel.esm.js | 4 +- .../spreadsheet/bundle/chart_panels.esm.js | 20 +- .../src/spreadsheet/bundle/filter.esm.js | 4 +- .../bundle/filter_panel_datasources.esm.js | 10 +- .../src/spreadsheet/bundle/odoo_panels.esm.js | 2 +- .../src/spreadsheet/bundle/spreadsheet.xml | 32 ++- .../bundle/spreadsheet_action.esm.js | 2 +- .../bundle/spreadsheet_renderer.esm.js | 4 +- .../src/spreadsheet/graph_controller.esm.js | 40 ++-- .../src/spreadsheet/list_controller.esm.js | 16 +- .../src/spreadsheet/list_renderer.esm.js | 106 +++++----- .../src/spreadsheet/pivot_controller.esm.js | 108 +++++----- .../static/src/spreadsheet/spreadsheet.xml | 8 +- .../views/spreadsheet_spreadsheet.xml | 2 +- .../spreadsheet_spreadsheet_import.xml | 12 +- 22 files changed, 373 insertions(+), 205 deletions(-) create mode 100644 .eslintrc.yml diff --git a/.copier-answers.yml b/.copier-answers.yml index a9ca7243..ba065f90 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.21.1 +_commit: v1.24 _src_path: https://github.com/OCA/oca-addons-repo-template.git additional_ruff_rules: [] ci: GitHub diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 00000000..0b382039 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,188 @@ +env: + browser: true + es6: true + +# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 +parserOptions: + ecmaVersion: 2022 + +overrides: + - files: + - "**/*.esm.js" + parserOptions: + sourceType: module + +# Globals available in Odoo that shouldn't produce errorings +globals: + _: readonly + $: readonly + fuzzy: readonly + jQuery: readonly + moment: readonly + odoo: readonly + openerp: readonly + owl: readonly + luxon: readonly + +# Styling is handled by Prettier, so we only need to enable AST rules; +# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890 +rules: + accessor-pairs: warn + array-callback-return: warn + callback-return: warn + capitalized-comments: + - warn + - always + - ignoreConsecutiveComments: true + ignoreInlineComments: true + complexity: + - warn + - 15 + constructor-super: warn + dot-notation: warn + eqeqeq: warn + global-require: warn + handle-callback-err: warn + id-blacklist: warn + id-match: warn + init-declarations: error + max-depth: warn + max-nested-callbacks: warn + max-statements-per-line: warn + no-alert: warn + no-array-constructor: warn + no-caller: warn + no-case-declarations: warn + no-class-assign: warn + no-cond-assign: error + no-const-assign: error + no-constant-condition: warn + no-control-regex: warn + no-debugger: error + no-delete-var: warn + no-div-regex: warn + no-dupe-args: error + no-dupe-class-members: error + no-dupe-keys: error + no-duplicate-case: error + no-duplicate-imports: error + no-else-return: warn + no-empty-character-class: warn + no-empty-function: error + no-empty-pattern: error + no-empty: warn + no-eq-null: error + no-eval: error + no-ex-assign: error + no-extend-native: warn + no-extra-bind: warn + no-extra-boolean-cast: warn + no-extra-label: warn + no-fallthrough: warn + no-func-assign: error + no-global-assign: error + no-implicit-coercion: + - warn + - allow: ["~"] + no-implicit-globals: warn + no-implied-eval: warn + no-inline-comments: warn + no-inner-declarations: warn + no-invalid-regexp: warn + no-irregular-whitespace: warn + no-iterator: warn + no-label-var: warn + no-labels: warn + no-lone-blocks: warn + no-lonely-if: error + no-mixed-requires: error + no-multi-str: warn + no-native-reassign: error + no-negated-condition: warn + no-negated-in-lhs: error + no-new-func: warn + no-new-object: warn + no-new-require: warn + no-new-symbol: warn + no-new-wrappers: warn + no-new: warn + no-obj-calls: warn + no-octal-escape: warn + no-octal: warn + no-param-reassign: warn + no-path-concat: warn + no-process-env: warn + no-process-exit: warn + no-proto: warn + no-prototype-builtins: warn + no-redeclare: warn + no-regex-spaces: warn + no-restricted-globals: warn + no-restricted-imports: warn + no-restricted-modules: warn + no-restricted-syntax: warn + no-return-assign: error + no-script-url: warn + no-self-assign: warn + no-self-compare: warn + no-sequences: warn + no-shadow-restricted-names: warn + no-shadow: warn + no-sparse-arrays: warn + no-sync: warn + no-this-before-super: warn + no-throw-literal: warn + no-undef-init: warn + no-undef: error + no-unmodified-loop-condition: warn + no-unneeded-ternary: error + no-unreachable: error + no-unsafe-finally: error + no-unused-expressions: error + no-unused-labels: error + no-unused-vars: error + no-use-before-define: error + no-useless-call: warn + no-useless-computed-key: warn + no-useless-concat: warn + no-useless-constructor: warn + no-useless-escape: warn + no-useless-rename: warn + no-void: warn + no-with: warn + operator-assignment: [error, always] + prefer-const: warn + radix: warn + require-yield: warn + sort-imports: warn + spaced-comment: [error, always] + strict: [error, function] + use-isnan: error + valid-jsdoc: + - warn + - prefer: + arg: param + argument: param + augments: extends + constructor: class + exception: throws + func: function + method: function + prop: property + return: returns + virtual: abstract + yield: yields + preferType: + array: Array + bool: Boolean + boolean: Boolean + number: Number + object: Object + str: String + string: String + requireParamDescription: false + requireReturn: false + requireReturnDescription: false + requireReturnType: false + valid-typeof: warn + yoda: warn diff --git a/.gitignore b/.gitignore index 0090721f..2b045db3 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,15 @@ var/ *.egg *.eggs +# Debian packages +*.deb + +# Redhat packages +*.rpm + +# MacOS packages +*.dmg + # Installer logs pip-log.txt pip-delete-this-directory.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ebd31027..31036037 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: hooks: - id: whool-init - repo: https://github.com/oca/maintainer-tools - rev: 9a170331575a265c092ee6b24b845ec508e8ef75 + rev: d5fab7ee87fceee858a3d01048c78a548974d935 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons diff --git a/spreadsheet_oca/__manifest__.py b/spreadsheet_oca/__manifest__.py index 2e46835b..be38cd52 100644 --- a/spreadsheet_oca/__manifest__.py +++ b/spreadsheet_oca/__manifest__.py @@ -5,7 +5,7 @@ "name": "Spreadsheet Oca", "summary": """ Allow to edit spreadsheets""", - "version": "16.0.1.3.0", + "version": "17.0.1.0.0", "license": "AGPL-3", "author": "CreuBlanca,Odoo Community Association (OCA)", "website": "https://github.com/OCA/spreadsheet", diff --git a/spreadsheet_oca/models/ir_websocket.py b/spreadsheet_oca/models/ir_websocket.py index 775caf0c..d1b643ba 100644 --- a/spreadsheet_oca/models/ir_websocket.py +++ b/spreadsheet_oca/models/ir_websocket.py @@ -43,7 +43,8 @@ def _build_bus_channel_list(self, channels): model_name, "read", raise_exception=False ): continue - # If user don't have access to the model, we don't even try to read + # If user don't have access to the model, we don't + # even try to read document = self.env[model_name].search( [("id", "=", res_id)], limit=1 diff --git a/spreadsheet_oca/models/spreadsheet_spreadsheet_import_mode.py b/spreadsheet_oca/models/spreadsheet_spreadsheet_import_mode.py index 63f19019..6bbad836 100644 --- a/spreadsheet_oca/models/spreadsheet_spreadsheet_import_mode.py +++ b/spreadsheet_oca/models/spreadsheet_spreadsheet_import_mode.py @@ -7,7 +7,7 @@ class SpreadsheetSpreadsheetImportMode(models.Model): _name = "spreadsheet.spreadsheet.import.mode" _description = "Import Mode" - _order = "sequence asc" + _order = "sequence asc, id" _rec_name = "name" sequence = fields.Integer(default=20) diff --git a/spreadsheet_oca/static/src/spreadsheet/bundle/chart_panel.esm.js b/spreadsheet_oca/static/src/spreadsheet/bundle/chart_panel.esm.js index c69c4370..dc422f8d 100644 --- a/spreadsheet_oca/static/src/spreadsheet/bundle/chart_panel.esm.js +++ b/spreadsheet_oca/static/src/spreadsheet/bundle/chart_panel.esm.js @@ -1,7 +1,7 @@ /** @odoo-module */ import { patch } from "@web/core/utils/patch"; -import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended"; +import * as spreadsheet from "@odoo/o-spreadsheet"; const { chartRegistry } = spreadsheet.registries; const { ChartPanel } = spreadsheet.components; @@ -9,7 +9,7 @@ export function isOdooKey(code) { return code.startsWith("odoo_"); } -patch(ChartPanel.prototype, "spreadsheet_oca.ChartPanel", { +patch(ChartPanel.prototype, { get chartTypes() { return this.filterChartTypes(isOdooKey(this.getChartDefinition().type)); }, diff --git a/spreadsheet_oca/static/src/spreadsheet/bundle/chart_panels.esm.js b/spreadsheet_oca/static/src/spreadsheet/bundle/chart_panels.esm.js index 47820e29..c3cc1c24 100644 --- a/spreadsheet_oca/static/src/spreadsheet/bundle/chart_panels.esm.js +++ b/spreadsheet_oca/static/src/spreadsheet/bundle/chart_panels.esm.js @@ -3,7 +3,7 @@ import { Domain } from "@web/core/domain"; import { Many2OneField } from "@web/views/fields/many2one/many2one_field"; import { patch } from "@web/core/utils/patch"; -import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended"; +import * as spreadsheet from "@odoo/o-spreadsheet"; import { useService } from "@web/core/utils/hooks"; const { @@ -54,31 +54,19 @@ const menuChartProps = { }, }; -patch( - LineBarPieConfigPanel.prototype, - "spreadsheet_oca.LineBarPieConfigPanel", - menuChartProps -); +patch(LineBarPieConfigPanel.prototype, menuChartProps); LineBarPieConfigPanel.components = { ...LineBarPieConfigPanel.components, Many2OneField, }; -patch( - ScorecardChartConfigPanel.prototype, - "spreadsheet_oca.ScorecardChartConfigPanel", - menuChartProps -); +patch(ScorecardChartConfigPanel.prototype, menuChartProps); ScorecardChartConfigPanel.components = { ...ScorecardChartConfigPanel.components, Many2OneField, }; -patch( - GaugeChartConfigPanel.prototype, - "spreadsheet_oca.GaugeChartConfigPanel", - menuChartProps -); +patch(GaugeChartConfigPanel.prototype, menuChartProps); GaugeChartConfigPanel.components = { ...GaugeChartConfigPanel.components, Many2OneField, diff --git a/spreadsheet_oca/static/src/spreadsheet/bundle/filter.esm.js b/spreadsheet_oca/static/src/spreadsheet/bundle/filter.esm.js index 7529aced..3fdca888 100644 --- a/spreadsheet_oca/static/src/spreadsheet/bundle/filter.esm.js +++ b/spreadsheet_oca/static/src/spreadsheet/bundle/filter.esm.js @@ -1,14 +1,14 @@ /** @odoo-module **/ import { Component, onWillStart, useState } from "@odoo/owl"; -import { _lt, _t } from "web.core"; +import { _lt, _t } from "@web/core/l10n/translation"; import { FilterValue } from "@spreadsheet/global_filters/components/filter_value/filter_value"; import { ModelFieldSelector } from "@web/core/model_field_selector/model_field_selector"; import { ModelSelector } from "@web/core/model_selector/model_selector"; import { RELATIVE_DATE_RANGE_TYPES } from "@spreadsheet/helpers/constants"; import { globalFiltersFieldMatchers } from "@spreadsheet/global_filters/plugins/global_filters_core_plugin"; -import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended"; +import * as spreadsheet from "@odoo/o-spreadsheet"; import { useService } from "@web/core/utils/hooks"; const { topbarMenuRegistry } = spreadsheet.registries; diff --git a/spreadsheet_oca/static/src/spreadsheet/bundle/filter_panel_datasources.esm.js b/spreadsheet_oca/static/src/spreadsheet/bundle/filter_panel_datasources.esm.js index 585d6e6b..f2d48afc 100644 --- a/spreadsheet_oca/static/src/spreadsheet/bundle/filter_panel_datasources.esm.js +++ b/spreadsheet_oca/static/src/spreadsheet/bundle/filter_panel_datasources.esm.js @@ -4,9 +4,9 @@ import { Component, onWillStart, onWillUpdateProps } from "@odoo/owl"; import { Domain } from "@web/core/domain"; import { DomainSelector } from "@web/core/domain_selector/domain_selector"; import { DomainSelectorDialog } from "@web/core/domain_selector_dialog/domain_selector_dialog"; -import { _t } from "web.core"; -import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended"; -import { time_to_str } from "web.time"; +import { _t } from "@web/core/l10n/translation"; +import * as spreadsheet from "@odoo/o-spreadsheet"; +import { formatDateTime } from "@web/core/l10n/dates"; import { useService } from "@web/core/utils/hooks"; import { FormViewDialog } from "@web/views/view_dialogs/form_view_dialog"; import { makeDynamicRows } from "../utils/dynamic_row_generator.esm"; @@ -87,7 +87,7 @@ export class PivotPanelDisplay extends Component { get lastUpdate() { const lastUpdate = this.PivotDataSource.lastUpdate; if (lastUpdate) { - return time_to_str(new Date(lastUpdate)); + return formatDateTime(new Date(lastUpdate), { format: "HH:mm:ss" }); } return _t("not updated"); } @@ -214,7 +214,7 @@ export class ListPanelDisplay extends Component { get lastUpdate() { const lastUpdate = this.ListDataSource.lastUpdate; if (lastUpdate) { - return time_to_str(new Date(lastUpdate)); + return formatDateTime(new Date(lastUpdate), { format: "HH:mm:ss" }); } return _t("not updated"); } diff --git a/spreadsheet_oca/static/src/spreadsheet/bundle/odoo_panels.esm.js b/spreadsheet_oca/static/src/spreadsheet/bundle/odoo_panels.esm.js index 2edd84df..98cf26f0 100644 --- a/spreadsheet_oca/static/src/spreadsheet/bundle/odoo_panels.esm.js +++ b/spreadsheet_oca/static/src/spreadsheet/bundle/odoo_panels.esm.js @@ -2,7 +2,7 @@ import { Domain } from "@web/core/domain"; import { Many2OneField } from "@web/views/fields/many2one/many2one_field"; -import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended"; +import * as spreadsheet from "@odoo/o-spreadsheet"; import { useService } from "@web/core/utils/hooks"; const { chartSidePanelComponentRegistry } = spreadsheet.registries; diff --git a/spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet.xml b/spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet.xml index b29117a1..b03c1dd1 100644 --- a/spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet.xml +++ b/spreadsheet_oca/static/src/spreadsheet/bundle/spreadsheet.xml @@ -1,7 +1,7 @@ - +
- + - +
- + - +
- +
Add text
- +
Label @@ -312,7 +312,7 @@
- + - + name is required - +