diff --git a/.copier-answers.yml b/.copier-answers.yml index 4591e9f48ef..a8c33b7db53 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,8 +1,7 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.29 +_commit: v1.43 _src_path: git+https://github.com/OCA/oca-addons-repo-template additional_ruff_rules: [] -ci: GitHub convert_readme_fragments_to_markdown: true enable_checklog_odoo: true generate_requirements_txt: true @@ -17,6 +16,7 @@ odoo_test_flavor: Both odoo_version: 18.0 org_name: Odoo Community Association (OCA) org_slug: OCA +postgres_image: '' rebel_module_groups: [] repo_description: knowledge repo_name: knowledge diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..e0d56685a95 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +test-requirements.txt merge=union diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 5eb021ef153..72aac6e1e37 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,3 +1,4 @@ + name: pre-commit on: @@ -16,7 +17,9 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" + cache: 'pip' + cache-dependency-path: '.pre-commit-config.yaml' - name: Get python version run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - uses: actions/cache@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a06488079fe..97ed5dfd4ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: makepot: "true" services: postgres: - image: postgres:12.0 + image: postgres:12 env: POSTGRES_USER: odoo POSTGRES_PASSWORD: odoo @@ -65,6 +65,13 @@ jobs: run: oca_init_test_database - name: Run tests run: oca_run_tests + - name: Upload screenshots from JS tests + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: Screenshots of failed JS tests - ${{ matrix.name }}${{ join(matrix.include) }} + path: /tmp/odoo_tests/${{ env.PGDATABASE }} + if-no-files-found: ignore - uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f74868bed76..6803c4b7fb2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ exclude: | # You don't usually want a bot to modify your legal texts (LICENSE.*|COPYING.*) default_language_version: - python: python3 + python: python3.12 node: "22.9.0" repos: - repo: local @@ -38,12 +38,17 @@ repos: entry: found a en.po file language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' + - id: obsolete dotfiles + name: obsolete dotfiles + entry: found obsolete files; remove them + files: '^(\.travis\.yml|\.t2d\.yml|CONTRIBUTING\.md|\.prettierrc\.yml|\.eslintrc\.yml)$' + language: fail - repo: https://github.com/sbidoul/whool - rev: v1.2 + rev: v1.3 hooks: - id: whool-init - repo: https://github.com/oca/maintainer-tools - rev: bf9ecb9938b6a5deca0ff3d870fbd3f33341fded + rev: b89f767503be6ab2b11e4f50a7557cb20066e667 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons @@ -95,6 +100,7 @@ repos: additional_dependencies: - "eslint@9.12.0" - "eslint-plugin-jsdoc@50.3.1" + - "globals@16.0.0" - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: diff --git a/.pylintrc b/.pylintrc index 7c62b6d2edd..197cb673705 100644 --- a/.pylintrc +++ b/.pylintrc @@ -25,19 +25,25 @@ disable=all enable=anomalous-backslash-in-string, api-one-deprecated, api-one-multi-together, - assignment-from-none, - attribute-deprecated, class-camelcase, - dangerous-default-value, dangerous-view-replace-wo-priority, - development-status-allowed, duplicate-id-csv, - duplicate-key, duplicate-xml-fields, duplicate-xml-record-id, eval-referenced, - eval-used, incoherent-interpreter-exec-perm, + openerp-exception-warning, + redundant-modulename-xml, + relative-import, + rst-syntax-error, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + assignment-from-none, + attribute-deprecated, + dangerous-default-value, + development-status-allowed, + duplicate-key, + eval-used, license-allowed, manifest-author-string, manifest-deprecated-key, @@ -48,73 +54,68 @@ enable=anomalous-backslash-in-string, method-inverse, method-required-super, method-search, - openerp-exception-warning, pointless-statement, pointless-string-statement, print-used, redundant-keyword-arg, - redundant-modulename-xml, reimported, - relative-import, return-in-init, - rst-syntax-error, sql-injection, too-few-format-args, translation-field, translation-required, unreachable, use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, create-user-wo-reset-password, dangerous-filter-wo-user, dangerous-qweb-replace-wo-priority, deprecated-data-xml-node, deprecated-openerp-xml-node, duplicate-po-message-definition, - except-pass, file-not-used, + missing-newline-extrafiles, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + str-format-used, + unnecessary-utf8-coding-comment, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + attribute-string-redundant, + consider-merging-classes-inherited, + context-overridden, + except-pass, invalid-commit, manifest-maintainers-list, - missing-newline-extrafiles, missing-readme, missing-return, odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, renamed-field-parameter, resource-not-exist, - str-format-used, test-folder-imported, translation-contains-variable, translation-positional-used, - unnecessary-utf8-coding-comment, website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, external-request-timeout, - # messages that do not cause the lint step to fail - consider-merging-classes-inherited, + missing-manifest-dependency, + too-complex,, create-user-wo-reset-password, dangerous-filter-wo-user, - deprecated-module, file-not-used, - invalid-commit, - missing-manifest-dependency, missing-newline-extrafiles, - missing-readme, no-utf8-coding-comment, - odoo-addons-relative-import, old-api7-method-defined, + unnecessary-utf8-coding-comment, + # messages that do not cause the lint step to fail + consider-merging-classes-inherited, + deprecated-module, + invalid-commit, + missing-readme, + odoo-addons-relative-import, redefined-builtin, - too-complex, - unnecessary-utf8-coding-comment + manifest-external-assets [REPORTS] diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 018fd61cdd7..73674c04d42 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -17,19 +17,25 @@ disable=all enable=anomalous-backslash-in-string, api-one-deprecated, api-one-multi-together, - assignment-from-none, - attribute-deprecated, class-camelcase, - dangerous-default-value, dangerous-view-replace-wo-priority, - development-status-allowed, duplicate-id-csv, - duplicate-key, duplicate-xml-fields, duplicate-xml-record-id, eval-referenced, - eval-used, incoherent-interpreter-exec-perm, + openerp-exception-warning, + redundant-modulename-xml, + relative-import, + rst-syntax-error, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + assignment-from-none, + attribute-deprecated, + dangerous-default-value, + development-status-allowed, + duplicate-key, + eval-used, license-allowed, manifest-author-string, manifest-deprecated-key, @@ -40,56 +46,50 @@ enable=anomalous-backslash-in-string, method-inverse, method-required-super, method-search, - openerp-exception-warning, pointless-statement, pointless-string-statement, print-used, redundant-keyword-arg, - redundant-modulename-xml, reimported, - relative-import, return-in-init, - rst-syntax-error, sql-injection, too-few-format-args, translation-field, translation-required, unreachable, use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, create-user-wo-reset-password, dangerous-filter-wo-user, dangerous-qweb-replace-wo-priority, deprecated-data-xml-node, deprecated-openerp-xml-node, duplicate-po-message-definition, - except-pass, file-not-used, + missing-newline-extrafiles, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + str-format-used, + unnecessary-utf8-coding-comment, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + attribute-string-redundant, + consider-merging-classes-inherited, + context-overridden, + except-pass, invalid-commit, manifest-maintainers-list, - missing-newline-extrafiles, missing-readme, missing-return, odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, renamed-field-parameter, resource-not-exist, - str-format-used, test-folder-imported, translation-contains-variable, translation-positional-used, - unnecessary-utf8-coding-comment, website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, external-request-timeout [REPORTS] diff --git a/README.md b/README.md index e3bd6dbc9b5..5afd4a00c0b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ +[![Support the OCA](https://odoo-community.org/readme-banner-image)](https://odoo-community.org/get-involved?utm_source=repo-readme) + +# knowledge [![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=18.0) [![Pre-commit Status](https://github.com/OCA/knowledge/actions/workflows/pre-commit.yml/badge.svg?branch=18.0)](https://github.com/OCA/knowledge/actions/workflows/pre-commit.yml?query=branch%3A18.0) [![Build Status](https://github.com/OCA/knowledge/actions/workflows/test.yml/badge.svg?branch=18.0)](https://github.com/OCA/knowledge/actions/workflows/test.yml?query=branch%3A18.0) @@ -7,8 +10,6 @@ -# knowledge - knowledge @@ -21,19 +22,19 @@ Available addons ---------------- addon | version | maintainers | summary --- | --- | --- | --- -[attachment_preview](attachment_preview/) | 18.0.1.0.0 | | Preview attachments supported by Viewer.js +[attachment_preview](attachment_preview/) | 18.0.1.0.1 | | Preview attachments supported by Viewer.js [attachment_zipped_download](attachment_zipped_download/) | 18.0.1.0.0 | | Attachment Zipped Download [document_knowledge](document_knowledge/) | 18.0.1.0.2 | | Documents Knowledge -[document_page](document_page/) | 18.0.2.1.1 | | Document Page +[document_page](document_page/) | 18.0.2.1.2 | | Document Page [document_page_access_group](document_page_access_group/) | 18.0.1.0.1 | | Choose groups to access document pages [document_page_access_group_user_role](document_page_access_group_user_role/) | 18.0.1.0.0 | victoralmau | Document Page Access Group User Role -[document_page_approval](document_page_approval/) | 18.0.1.1.1 | | Document Page Approval +[document_page_approval](document_page_approval/) | 18.0.1.2.0 | | Document Page Approval [document_page_group](document_page_group/) | 18.0.1.0.0 | | Define access groups on documents [document_page_partner](document_page_partner/) | 18.0.1.0.0 | | Allows to link doucment pages to a partner [document_page_product](document_page_product/) | 18.0.1.0.0 | victoralmau | This module links document pages to products [document_page_project](document_page_project/) | 18.0.1.0.0 | LoisRForgeFlow | This module links document pages to projects [document_page_project_task](document_page_project_task/) | 18.0.2.0.0 | marcelsavegnago | This module links document pages to project tasks -[document_page_reference](document_page_reference/) | 18.0.2.1.2 | etobella | Include references on document pages +[document_page_reference](document_page_reference/) | 18.0.2.1.3 | etobella | Include references on document pages [document_page_tag](document_page_tag/) | 18.0.1.0.0 | | Allows you to assign tags or keywords to pages and search for them afterwards [document_url](document_url/) | 18.0.1.0.1 | | URL attachment diff --git a/attachment_preview/README.rst b/attachment_preview/README.rst index 077eec42b44..df487bd0c4d 100644 --- a/attachment_preview/README.rst +++ b/attachment_preview/README.rst @@ -11,7 +11,7 @@ Preview attachments !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:e9abcd982f1b988dc4c79d2c451320fddb5fc1289f44e8b7c178c917b2bd4d1e + !! source digest: sha256:badc7aad1a4bee3f65173d08f56b91d13166d0c26644edf8475aa249016995e1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/attachment_preview/__manifest__.py b/attachment_preview/__manifest__.py index b704f59f80d..2d982faf056 100644 --- a/attachment_preview/__manifest__.py +++ b/attachment_preview/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Preview attachments", - "version": "18.0.1.0.0", + "version": "18.0.1.0.1", "author": "Therp BV," "Onestein," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/knowledge", "license": "AGPL-3", diff --git a/attachment_preview/static/description/index.html b/attachment_preview/static/description/index.html index 11902dea7ee..d3e04bb22d0 100644 --- a/attachment_preview/static/description/index.html +++ b/attachment_preview/static/description/index.html @@ -372,7 +372,7 @@

Preview attachments

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:e9abcd982f1b988dc4c79d2c451320fddb5fc1289f44e8b7c178c917b2bd4d1e +!! source digest: sha256:badc7aad1a4bee3f65173d08f56b91d13166d0c26644edf8475aa249016995e1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

This addon allows to preview attachments supported by diff --git a/attachment_preview/static/src/js/attachmentPreviewWidget.esm.js b/attachment_preview/static/src/js/attachmentPreviewWidget.esm.js index 845ccc78288..0d080055d60 100644 --- a/attachment_preview/static/src/js/attachmentPreviewWidget.esm.js +++ b/attachment_preview/static/src/js/attachmentPreviewWidget.esm.js @@ -35,7 +35,7 @@ export class AttachmentPreviewWidget extends Component { _onPopoutClick() { if (!this.attachments[this.state.activeIndex]) return; - // eslint-disable-next-line no-undef + window.open(this.attachments[this.state.activeIndex].previewUrl); } diff --git a/attachment_preview/static/src/js/mail_core/attachment_list.esm.js b/attachment_preview/static/src/js/mail_core/attachment_list.esm.js index 04fa3eb6eae..6a2583311f6 100644 --- a/attachment_preview/static/src/js/mail_core/attachment_list.esm.js +++ b/attachment_preview/static/src/js/mail_core/attachment_list.esm.js @@ -4,7 +4,6 @@ import {patch} from "@web/core/utils/patch"; patch(AttachmentList.prototype, { _onPreviewAttachment(attachment) { - // eslint-disable-next-line no-undef var $target = $(event.currentTarget); var split_screen = $target.attr("data-target") !== "new"; showPreview( diff --git a/attachment_preview/static/src/js/utils.esm.js b/attachment_preview/static/src/js/utils.esm.js index 85f626a0e68..b6e3c04bc82 100644 --- a/attachment_preview/static/src/js/utils.esm.js +++ b/attachment_preview/static/src/js/utils.esm.js @@ -25,11 +25,9 @@ export function getUrl( var url = ""; if (attachment_url) { if (attachment_url.slice(0, 21) === "/web/static/lib/pdfjs") { - // eslint-disable-next-line no-undef url = (window.location.origin || "") + attachment_url; } else { url = - // eslint-disable-next-line no-undef (window.location.origin || "") + "/attachment_preview/static/lib/ViewerJS/index.html" + "?type=" + @@ -38,13 +36,11 @@ export function getUrl( encodeURIComponent(attachment_title) + "&zoom=automatic" + "#" + - // eslint-disable-next-line no-undef attachment_url.replace(window.location.origin, ""); } return url; } url = - // eslint-disable-next-line no-undef (window.location.origin || "") + "/attachment_preview/static/lib/ViewerJS/index.html" + "?type=" + @@ -74,7 +70,6 @@ export function showPreview( attachment_info_list, }); } else { - // eslint-disable-next-line no-undef window.open( getUrl( attachment_id, diff --git a/attachment_preview/static/src/js/viewerjs_tweaks.js b/attachment_preview/static/src/js/viewerjs_tweaks.js index 813eb4daca0..e5847ca8519 100644 --- a/attachment_preview/static/src/js/viewerjs_tweaks.js +++ b/attachment_preview/static/src/js/viewerjs_tweaks.js @@ -5,13 +5,12 @@ // OpenERP's context (function (original_Viewer) { "use strict"; - // eslint-disable-next-line no-undef + window.Viewer = function (plugin, parameters) { if (!plugin) { - // eslint-disable-next-line no-undef, no-alert + // eslint-disable-next-line no-alert alert("Unsupported file type"); } return original_Viewer(plugin, parameters); }; - // eslint-disable-next-line no-undef })(window.Viewer); diff --git a/checklog-odoo.cfg b/checklog-odoo.cfg index 0b55b7bf663..58d43aa6662 100644 --- a/checklog-odoo.cfg +++ b/checklog-odoo.cfg @@ -1,3 +1,5 @@ [checklog-odoo] ignore= WARNING.* 0 failed, 0 error\(s\).* + WARNING .* Killing chrome descendants-or-self .* + WARNING.* Missing widget: res_partner_many2one for field of type many2one.* diff --git a/document_page/README.rst b/document_page/README.rst index a9cef6b2d17..1541b4bc5fc 100644 --- a/document_page/README.rst +++ b/document_page/README.rst @@ -11,7 +11,7 @@ Document Page !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:98a799e3629850c2eeba7be0a3ad000746bc10955ef4a5836a6d86f67c116549 + !! source digest: sha256:657bfefae08e3e02a43481bc40dd11d1ef07f7aa53ebcf3c1dab368212f4dbf6 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/document_page/__manifest__.py b/document_page/__manifest__.py index 17a7f68afb0..9a2368a94e3 100644 --- a/document_page/__manifest__.py +++ b/document_page/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Document Page", - "version": "18.0.2.1.1", + "version": "18.0.2.1.2", "category": "Knowledge Management", "author": "OpenERP SA, Odoo Community Association (OCA)", "images": [ diff --git a/document_page/static/description/index.html b/document_page/static/description/index.html index d56e05651ba..fe5b2faa95a 100644 --- a/document_page/static/description/index.html +++ b/document_page/static/description/index.html @@ -372,7 +372,7 @@

Document Page

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:98a799e3629850c2eeba7be0a3ad000746bc10955ef4a5836a6d86f67c116549 +!! source digest: sha256:657bfefae08e3e02a43481bc40dd11d1ef07f7aa53ebcf3c1dab368212f4dbf6 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

This module allows you to write web pages for internal documentation.

diff --git a/document_page/static/src/js/document_page_kanban_controller.esm.js b/document_page/static/src/js/document_page_kanban_controller.esm.js index 7ad18ada056..84baa01994a 100644 --- a/document_page/static/src/js/document_page_kanban_controller.esm.js +++ b/document_page/static/src/js/document_page_kanban_controller.esm.js @@ -5,7 +5,6 @@ export class DocumentPageKanbanController extends KanbanController { * @param {Object} record */ async openRecord(record) { - // eslint-disable-next-line no-undef const element = document.querySelector( `.o_kanban_record[data-id="${record.id}"] .o_document_page_kanban_boxes a` ); diff --git a/document_page_approval/README.rst b/document_page_approval/README.rst index 73db242b581..bad71157a8d 100644 --- a/document_page_approval/README.rst +++ b/document_page_approval/README.rst @@ -11,7 +11,7 @@ Document Page Approval !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:076e3494c42033cf34cf3d9a7a92ea7f0d7982d04738360bec6ff9604ee1b357 + !! source digest: sha256:347ffb497be642e1f10188011bef36f3c3352dfc195b6aed70de618c0e7c79dc !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/document_page_approval/__manifest__.py b/document_page_approval/__manifest__.py index 919a398d285..a05d537df8a 100644 --- a/document_page_approval/__manifest__.py +++ b/document_page_approval/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Document Page Approval", - "version": "18.0.1.1.1", + "version": "18.0.1.2.0", "author": "Savoir-faire Linux, Odoo Community Association (OCA)", "website": "https://github.com/OCA/knowledge", "license": "AGPL-3", diff --git a/document_page_approval/models/document_page.py b/document_page_approval/models/document_page.py index 1977a769999..d57cb9e3073 100644 --- a/document_page_approval/models/document_page.py +++ b/document_page_approval/models/document_page.py @@ -88,6 +88,7 @@ def _compute_approver_group_ids(self): page.approver_group_ids = res @api.depends("is_approval_required", "approver_group_ids") + @api.depends_context("uid") def _compute_am_i_approver(self): """Check if the current user can approve changes to this page.""" for rec in self: @@ -111,6 +112,7 @@ def can_user_approve_this_page(self, user): # to approve, user must belong to any of the approver groups return len(user.groups_id & self.approver_group_ids) > 0 + @api.depends_context("uid") def _compute_has_changes_pending_approval(self): history = self.env["document.page.history"] for rec in self: @@ -119,6 +121,7 @@ def _compute_has_changes_pending_approval(self): ) rec.has_changes_pending_approval = changes > 0 + @api.depends_context("uid") def _compute_user_has_drafts(self): history = self.env["document.page.history"] for rec in self: diff --git a/document_page_approval/models/document_page_history.py b/document_page_approval/models/document_page_history.py index af7558813f4..62499fe1152 100644 --- a/document_page_approval/models/document_page_history.py +++ b/document_page_approval/models/document_page_history.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models +from odoo import api, fields, models from odoo.exceptions import UserError from odoo.tools.misc import clean_context from odoo.tools.translate import _ @@ -143,6 +143,7 @@ def action_cancel_and_draft(self): self.action_cancel() self.action_draft() + @api.depends_context("uid") def _compute_am_i_owner(self): """Check if current user is the owner""" for rec in self: diff --git a/document_page_approval/static/description/index.html b/document_page_approval/static/description/index.html index a6f9022073c..97d65b4bddc 100644 --- a/document_page_approval/static/description/index.html +++ b/document_page_approval/static/description/index.html @@ -372,7 +372,7 @@

Document Page Approval

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:076e3494c42033cf34cf3d9a7a92ea7f0d7982d04738360bec6ff9604ee1b357 +!! source digest: sha256:347ffb497be642e1f10188011bef36f3c3352dfc195b6aed70de618c0e7c79dc !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

This module adds a workflow to approve page modifications and show the diff --git a/document_page_approval/tests/test_document_page_approval.py b/document_page_approval/tests/test_document_page_approval.py index de41f27da76..27cac61b06c 100644 --- a/document_page_approval/tests/test_document_page_approval.py +++ b/document_page_approval/tests/test_document_page_approval.py @@ -23,6 +23,20 @@ def setUpClass(cls): login="test-user2", groups="document_page_approval.group_document_approver_user", ) + cls.user_normal = new_test_user( + cls.env, + login="test_normal", + groups="document_knowledge.group_document_user,document_page.group_document_editor", + name="Test Normal User", + email="normal@example.com", + ) + cls.manager_user = new_test_user( + cls.env, + login="test_manager", + groups="document_page.group_document_manager", + name="Test Manager", + email="manager@example.com", + ) # Ensure user2 has the approver group cls.approver_gid = cls.env.ref( @@ -267,3 +281,64 @@ def test_diff_computation(self): ) chreq2._compute_diff() self.assertIsNotNone(chreq2.diff) + + def test_cache_am_i_approver(self): + """Ensure 'am_i_approver' is computed per-user and not cached globally.""" + page = self.page2 + + # Normal user evaluates the field first (Calculates and caches: False) + self.assertFalse(page.with_user(self.user_normal).am_i_approver) + + # Approver user evaluates it next. + self.assertTrue(page.with_user(self.user2).am_i_approver) + + def test_cache_am_i_owner(self): + """Ensure 'am_i_owner' is computed per-user and not cached globally.""" + page = self.page2 + # Normal user creates the change request (they are the owner) + chreq = self.history_obj.with_user(self.user_normal).create( + { + "page_id": page.id, + "summary": "Cache Test", + "content": "

User Normal Changes

", + } + ) + + # Approver user evaluates the field first (Calculates and caches: False) + self.assertFalse(chreq.with_user(self.user2).am_i_owner) + + # Normal user evaluates it next + self.assertTrue(chreq.with_user(self.user_normal).am_i_owner) + + def test_cache_user_has_drafts(self): + """Ensure 'user_has_drafts' is computed per-user and not cached globally.""" + page = self.page2 + # Normal user creates a draft change request + self.history_obj.with_user(self.user_normal).create( + { + "page_id": page.id, + "state": "draft", + } + ) + + # Approver evaluates the field first + self.assertFalse(page.with_user(self.user2).user_has_drafts) + + # Normal user evaluates it next + self.assertTrue(page.with_user(self.user_normal).user_has_drafts) + + def test_cache_has_changes_pending_approval(self): + """Ensure 'has_changes_pending_approval' is computed per-user and not cached.""" + page = self.page2 + # Create a pending approval change request using the Manager + # so it's NOT owned by the normal user. + chreq = self.history_obj.with_user(self.manager_user).create( + {"page_id": page.id, "content": "

Manager Change

"} + ) + chreq.with_user(self.manager_user).action_to_approve() + + # Normal user evaluates the field. + self.assertFalse(page.with_user(self.user_normal).has_changes_pending_approval) + + # Approver user evaluates it. + self.assertTrue(page.with_user(self.user2).has_changes_pending_approval) diff --git a/document_page_reference/README.rst b/document_page_reference/README.rst index 093801cf514..39071b1c8bb 100644 --- a/document_page_reference/README.rst +++ b/document_page_reference/README.rst @@ -11,7 +11,7 @@ Document Page Reference !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:99f7203545e099cb72ee70d72c03ea7075435ff2f7e0da356769e877104c62a8 + !! source digest: sha256:7ae4eea4b6e7501b923f3597e005c064c4b58658b2913d8c3bfd25b1a7f9494c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/document_page_reference/__manifest__.py b/document_page_reference/__manifest__.py index cd14e0a7677..7c370726841 100644 --- a/document_page_reference/__manifest__.py +++ b/document_page_reference/__manifest__.py @@ -5,7 +5,7 @@ "name": "Document Page Reference", "summary": """ Include references on document pages""", - "version": "18.0.2.1.2", + "version": "18.0.2.1.3", "license": "AGPL-3", "author": "Creu Blanca,Odoo Community Association (OCA)", "website": "https://github.com/OCA/knowledge", diff --git a/document_page_reference/static/description/index.html b/document_page_reference/static/description/index.html index 4e7d834ee04..adf3bc02c3d 100644 --- a/document_page_reference/static/description/index.html +++ b/document_page_reference/static/description/index.html @@ -372,7 +372,7 @@

Document Page Reference

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:99f7203545e099cb72ee70d72c03ea7075435ff2f7e0da356769e877104c62a8 +!! source digest: sha256:7ae4eea4b6e7501b923f3597e005c064c4b58658b2913d8c3bfd25b1a7f9494c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

This module allows to add a reference name on documents and simplifies diff --git a/document_page_reference/static/src/js/editor.esm.js b/document_page_reference/static/src/js/editor.esm.js index 416bfb851f4..0bbfa7bbdbb 100644 --- a/document_page_reference/static/src/js/editor.esm.js +++ b/document_page_reference/static/src/js/editor.esm.js @@ -9,7 +9,6 @@ class DocumentPageReferenceField extends HtmlField { this.orm = useService("orm"); this.action = useService("action"); onMounted(() => { - // eslint-disable-next-line no-undef const links = document.querySelectorAll(".oe_direct_line"); links.forEach((link) => { link.addEventListener("click", (event) => diff --git a/eslint.config.cjs b/eslint.config.cjs index 0d5731f89a8..dd0cbe0aef0 100644 --- a/eslint.config.cjs +++ b/eslint.config.cjs @@ -1,3 +1,4 @@ +var globals = require('globals'); jsdoc = require("eslint-plugin-jsdoc"); const config = [{ @@ -16,6 +17,8 @@ const config = [{ openerp: "readonly", owl: "readonly", luxon: "readonly", + QUnit: "readonly", + ...globals.browser, }, ecmaVersion: 2024, @@ -191,7 +194,7 @@ const config = [{ }, }, { - files: ["**/*.esm.js"], + files: ["**/*.esm.js", "**/*test.js"], languageOptions: { ecmaVersion: 2024,