Skip to content

[Refactor] Notes - #11971

Merged
SchrodingersGat merged 282 commits into
inventree:masterfrom
SchrodingersGat:block-notes
Aug 31, 2026
Merged

SchrodingersGat merged 282 commits into
inventree:masterfrom
SchrodingersGat:block-notes

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented May 20, 2026 •

Copy link
Copy Markdown
Member

Example Screenshots

Description Screenshot
Display Mode image
Edit Mode image
Rendered to report image

Generic Notes Table

The major item here is to move all notes into a new table, which has generic FK links to other items. This brings it into line with how we handle attachments, parameters, etc.

Multiple Notes

We can now specify multiple, separate notes per item. This is useful for keeping different types of notes separate - e.g. shipping instructions vs inspection instructions (for e.g.)

Render to report

Rendering notes to reports is now greatly improved. In particular, images are correctly handled now - and can even be resized based on the specified size in the HTML content

Editor Updates

Also introduces the possibility of a more intuitive notes editor.

At this stage, I am trialing BlockNote - which provides navite mantine support, and provides a "notion style" editing interface.

I am using the Rich Text Editor shipped as part of the Mantine framework.

Pros:

  • Intuitive, "modern" editing interface
  • Supports more content layout features
  • Resizable images

Cons:

  • Requires HTML formatting
  • Current notes use markdown

Tasks

  • Display note information (title / description / last updated by)
  • Allow edit notes (if user has permission)
  • Allow delete notes (if user has permission)
  • Client side sanitize of notes
  • Server side sanitize of notes
  • Support direct image upload (drag and drop / copy-paste)
  • Render notes in PDF reports
  • Ensure inline images are rendered correctly in PDF reports
  • Documentation
  • Data migration for existing notes
  • Data migration for existing notes image
  • Handle legacy "NotesImage" concept - how to detect and embed these images?
  • prevent navigation away when notes are dirty
  • Allow note selection from query params
  • Update demo dataset with notes / images / etc (BEFORE migration)
  • Apply data migration to demo dataset
  • Unit tests (backend)
  • Duplicate notes from existing instance - also copies embedded images
  • Playwright tests
  • Unit tests for data migrations
  • Remove "notes" field from any models which use the new approach
  • Delete the old "notes" mixin class
  • Support dark mode
  • Support localization
  • Remove old dependencies for simplemde
  • Delete old "delete_old_notes_images" task
  • Mark "delete_old_notes_images" task as outdated
  • Ensure users cannot upload notes against models they do not have permission for
  • Ensure users cannot upload note images against models they do not have permission for
  • Allow creation of note "templates" (edit via admin interface)
  • Create new notes from template note
  • Add documentation for note templates
  • Add some note templates to the demo dataset - Multi notes migration demo-dataset#122
  • Update app support (display multiple notes) - Support modern "Note" model inventree-app#859
  • Add CHANGELOG entry

Ideas for future work

  • Add plugin to link directly to attachments
  • Add plugin to link to other pages (e.g. parts / orders / etc)
  • Add plugin to render admonitions
  • Export notes?
  • Allow notes to be "scoped" to a certain group permission

@SchrodingersGat SchrodingersGat added this to the 1.4.0 milestone May 20, 2026
@SchrodingersGat SchrodingersGat added api Relates to the API refactor feature migration Data or schema migrations User Interface Related to the frontend / User Interface full-run Always do a full QC CI run labels May 20, 2026
@netlify

netlify Bot commented May 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit 778e57b
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a9502b4b128800008668ace

@SchrodingersGat
SchrodingersGat marked this pull request as draft May 20, 2026 12:41
@SchrodingersGat

Copy link
Copy Markdown
Member Author

@matmair @wolflu05 before I go too far with this I'd be interested in your feedback around two major points:

Data Structure Refactor: Are we on board with the idea of supporting multiple notes per item?

Editor: Do you have any objections to moving to a new editor, and move to HTML notes? We will obviously have to tackle any data sanitizing required here

@codecov

codecov Bot commented May 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.47409% with 102 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.04%. Comparing base (d39d026) to head (778e57b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11971      +/-   ##
==========================================
+ Coverage   87.02%   87.04%   +0.02%     
==========================================
  Files        1473     1479       +6     
  Lines       98712    99548     +836     
  Branches    11486    11321     -165     
==========================================
+ Hits        85903    86656     +753     
- Misses      12744    12826      +82     
- Partials       65       66       +1     
Flag Coverage Δ
backend 91.08% <91.82%> (+0.06%) ⬆️
migrations 38.37% <30.09%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 92.36% <96.43%> (+0.14%) ⬆️
Backend General 94.47% <97.42%> (+0.68%) ⬆️
Frontend 79.60% <80.70%> (-0.33%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matmair

matmair commented May 20, 2026 •

Copy link
Copy Markdown
Member

I think the general idea is very good; a few points/ideas:

  • I would like to see some tests in the final PR to ensure we do not leak data due to this migration
  • if we already build a new model we might as well add created, updated and created_by, updated_by fields
  • does a note owner make sense?
  • should we add user customizable types?
  • should we addnote states?
  • having a special "primary" note that still renders to the api seems like a good idea; i have seen a bunch of ppl use notes fields for all kind of plugins; this change would be pretty breaking

I like blocknote as a choice, the OpenProject and a bunch of other EU sovereign gov cloud products use it.
How we save/provide notes data in the future is still a bit of a question; there is markdown support from what I can tell. And if we are already switching data model why not use the native document format and just save a html (or markdown) representation on the side? That seems safer and better for future customizations of the editor capabilities.

Things i am unsure about:

  • what does rendering to reports look like? are existing reports breaking?
  • possible security problems?

@wolflu05

Copy link
Copy Markdown
Member

I also like the general idea, the current notes editor seems very limited. But I would appreciate if there would be some easy migration path from markdown based notes to the new format, and a method to render the new notes format to reports.

@SchrodingersGat SchrodingersGat added the breaking Indicates a major update or change which breaks compatibility label May 21, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member Author

But I would appreciate if there would be some easy migration path from markdown based notes to the new format

All markdown features should be forward-compatible. This will be fully tested. I don't want to lose any of my notes, either.

and a method to render the new notes format to reports.

100% will be supported and tested too.

The back-end storage of the notes will be editor-agnostic HTML. So rendering to reports will be easier (ideally) than markdown.

@SchrodingersGat SchrodingersGat modified the milestones: 1.4.0, 2.0.0 May 21, 2026
@wolflu05

Copy link
Copy Markdown
Member

Although this is a big breaking change in the InvenTree api as not only the endpoints change but also how notes are stored, i think this is a huge step forward. In general it looks good, curious what @matmair says. Unfortunately I won't have the time to do a full review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Major refactor of the notes system: replaces per-model markdown notes fields with a generic common.Note model (plus NotesImage), adds templates and a rich-text editor workflow in the frontend, updates duplication and reporting to use the new note model, and introduces an aggregated “instance info” endpoint to drive tab notification dots efficiently.

Changes:

  • Backend: add Note model + migrations to move legacy notes/images, replace InvenTreeNotesMixin with InvenTreeNoteMixin, update duplication + search + reports accordingly.
  • Frontend: new rich-text notes UI (including templates), new useInstanceInfo hook + tab dot refactor, and updated E2E coverage for notes flows.
  • Docs/CI: add documentation for notes and update workflows/test expectations to align with the new notes architecture.

Reviewed changes

Copilot reviewed 107 out of 110 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tasks.py Adds --parallel option for test invocation.
src/frontend/tests/pages/pui_part.spec.ts Updates Playwright notes test to new multi-note UI/flows.
src/frontend/src/pages/stock/TransferOrderDetail.tsx Uses useInstanceInfo to feed tab dot counts (params/attachments/notes).
src/frontend/src/pages/stock/StockDetail.tsx Uses useInstanceInfo; updates notes/attachments dots and duplicate flow wiring.
src/frontend/src/pages/stock/LocationDetail.tsx Uses useInstanceInfo for parameter dot count.
src/frontend/src/pages/sales/SalesOrderShipmentDetail.tsx Uses useInstanceInfo for counts; switches notes dot to note-count based.
src/frontend/src/pages/sales/SalesOrderDetail.tsx Uses useInstanceInfo for counts; updates notes panel dot logic.
src/frontend/src/pages/sales/ReturnOrderDetail.tsx Uses useInstanceInfo for counts; updates notes panel dot logic.
src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx Uses useInstanceInfo for counts; updates notes panel dot logic.
src/frontend/src/pages/part/PartDetail.tsx Uses useInstanceInfo and updates tab notification dots to count-based inputs.
src/frontend/src/pages/part/CategoryDetail.tsx Uses useInstanceInfo for parameter dot count.
src/frontend/src/pages/Index/Settings/AdminCenter/NoteTemplatePanel.tsx Adds admin-center panel for managing note templates.
src/frontend/src/pages/Index/Settings/AdminCenter/Index.tsx Registers “Note Templates” panel in admin center navigation.
src/frontend/src/pages/company/SupplierPartDetail.tsx Uses useInstanceInfo for counts; updates notes panel dot logic.
src/frontend/src/pages/company/ManufacturerPartDetail.tsx Uses useInstanceInfo for counts; updates notes panel dot logic.
src/frontend/src/pages/company/CompanyDetail.tsx Uses useInstanceInfo for counts; updates notes panel dot logic.
src/frontend/src/pages/build/BuildDetail.tsx Uses useInstanceInfo for counts; updates notes panel dot logic.
src/frontend/src/hooks/UseInstanceInfo.tsx Adds aggregated per-instance count query hook (instance-info endpoint).
src/frontend/src/forms/TransferOrderForms.tsx Adds copy_notes to duplicate options payload.
src/frontend/src/forms/StockForms.tsx Adds stock duplication UI field with copy_notes default + options.
src/frontend/src/forms/SalesOrderForms.tsx Adds copy_notes to duplicate options payload.
src/frontend/src/forms/ReturnOrderForms.tsx Adds copy_notes to duplicate options payload.
src/frontend/src/forms/PurchaseOrderForms.tsx Adds copy_notes to duplicate options payload.
src/frontend/src/forms/CompanyForms.tsx Adds copy_notes to duplicate options payload for company/manufacturer/supplier parts.
src/frontend/src/forms/CommonForms.tsx Adds form fieldsets for note creation + note templates.
src/frontend/src/forms/BuildForms.tsx Adds copy_notes to build duplication options payload.
src/frontend/src/components/render/Note.tsx Adds renderer for note templates in generic model rendering.
src/frontend/src/components/render/ModelRenderShim.ts Registers notetemplate renderer.
src/frontend/src/components/panels/ParametersPanel.tsx Switches notification dot to prop-driven parameter_count.
src/frontend/src/components/panels/PanelGroup.tsx Fixes static vs async notification-dot handling; upgrades dirty-navigation prompt UX.
src/frontend/src/components/panels/NotesPanel.tsx Switches notes dot to prop-driven note_count; delegates edit permission to editor.
src/frontend/src/components/panels/AttachmentPanel.tsx Switches attachment dot to prop-driven attachment_count.
src/frontend/src/components/items/ActionDropdown.tsx Adds configurable tooltip position to options dropdown.
src/frontend/src/components/editors/NotesEditor.css Adds rich-text editor table + image interaction styling.
src/frontend/package.json Adds tiptap/mantine editor deps; removes old markdown editor deps; adds glob resolution.
src/frontend/lib/enums/ModelType.tsx Adds notetemplate model type.
src/frontend/lib/enums/ModelInformation.tsx Adds model metadata for note templates (label, endpoint, settings URL).
src/frontend/lib/enums/ApiEndpoints.tsx Adds instance_info, note_list, notes_image_list; removes old notes-image upload endpoint.
src/backend/InvenTree/users/test_migrations.py Pins MFA migration base to avoid cross-app ordering flakiness.
src/backend/InvenTree/users/ruleset.py Adds common_note to ruleset ignore list.
src/backend/InvenTree/stock/test_api.py Adds API tests ensuring stock duplication copies notes by default (and can disable).
src/backend/InvenTree/stock/serializers.py Adds duplicate options to StockItem creation; removes legacy notes field exposure.
src/backend/InvenTree/stock/models.py Switches StockItem to InvenTreeNoteMixin.
src/backend/InvenTree/stock/migrations/0128_remove_stockitem_notes.py Removes notes field from StockItem.
src/backend/InvenTree/stock/api.py Applies duplication copy options (including notes) during stock item creation.
src/backend/InvenTree/report/tests.py Adds regression tests ensuring reports render notes correctly post-refactor.
src/backend/InvenTree/report/templatetags/report.py Adds {% note %} / {% note_instance %} tags with inline image resolution for PDFs.
src/backend/InvenTree/report/templates/report/inventree_transfer_order_report.html Removes markdownify load (notes now HTML via tag).
src/backend/InvenTree/report/templates/report/inventree_stock_location_report.html Renders stock item notes via {% note %}.
src/backend/InvenTree/report/templates/report/inventree_sales_order_shipment_report.html Removes markdownify load (notes now HTML via tag).
src/backend/InvenTree/report/templates/report/inventree_sales_order_report.html Removes markdownify load (notes now HTML via tag).
src/backend/InvenTree/report/templates/report/inventree_return_order_report.html Removes markdownify load (notes now HTML via tag).
src/backend/InvenTree/report/templates/report/inventree_purchase_order_report.html Removes markdownify load (notes now HTML via tag).
src/backend/InvenTree/report/templates/report/inventree_order_report_base.html Removes markdownify load (notes now HTML via tag).
src/backend/InvenTree/report/templates/report/inventree_build_order_report.html Renders build notes using {% note %} tag instead of markdown.
src/backend/InvenTree/part/test_api.py Updates part tests from legacy notes field to new Note API/model behavior.
src/backend/InvenTree/part/serializers.py Removes legacy notes serializer mixin; routes duplication through shared copy helper.
src/backend/InvenTree/part/models.py Switches Part to InvenTreeNoteMixin.
src/backend/InvenTree/part/migrations/0154_remove_part_notes.py Removes notes field from Part.
src/backend/InvenTree/part/fixtures/part.yaml Removes legacy notes fixture field.
src/backend/InvenTree/order/test_api.py Adds duplication tests for note copying; updates receive-item note semantics.
src/backend/InvenTree/order/serializers.py Removes legacy notes serializer mixin; adds copy-notes duplication support.
src/backend/InvenTree/order/models.py Switches relevant order models to InvenTreeNoteMixin; rethreads receive notes into tracking entries.
src/backend/InvenTree/order/migrations/0122_remove_purchaseorder_notes_remove_returnorder_notes_and_more.py Removes notes fields from order models.
src/backend/InvenTree/InvenTree/test_api.py Updates search tests to use new notes relation and adds distinctness regression test.
src/backend/InvenTree/InvenTree/serializers.py Removes NotesFieldMixin; extends duplication options + adds shared apply helper.
src/backend/InvenTree/InvenTree/sentry.py Fixes typo in comment.
src/backend/InvenTree/InvenTree/sanitizer.py Fixes typos in comments/constant name.
src/backend/InvenTree/InvenTree/models.py Adds InvenTreeNoteMixin; removes legacy InvenTreeNotesMixin.
src/backend/InvenTree/InvenTree/mixins.py Removes markdown-cleaning path from generic string cleaning.
src/backend/InvenTree/InvenTree/helpers.py Removes legacy markdown sanitization helper.
src/backend/InvenTree/InvenTree/filters.py Updates search_notes to work with multi-note relations and deduplicate results.
src/backend/InvenTree/InvenTree/apps.py Reorders obsolete task list.
src/backend/InvenTree/InvenTree/api_version.py Bumps API version and documents breaking notes API change.
src/backend/InvenTree/importer/tests.py Updates importer test expectations after notes field removal.
src/backend/InvenTree/company/test_api.py Adds duplication tests ensuring notes copy behavior for company-related models.
src/backend/InvenTree/company/serializers.py Removes legacy notes serializer mixin; adds copy-notes duplication support.
src/backend/InvenTree/company/models.py Switches company-related models to InvenTreeNoteMixin.
src/backend/InvenTree/company/migrations/0081_remove_company_notes_remove_manufacturerpart_notes_and_more.py Removes legacy notes fields from company models.
src/backend/InvenTree/common/validators.py Adds note model type validation + shared model/mixin option helpers.
src/backend/InvenTree/common/tests.py Adds tests for note image cleanup, cascade deletion, and copy-with-images; adds task tests.
src/backend/InvenTree/common/test_migrations.py Adds extensive migration tests for notes/images migration correctness and batching.
src/backend/InvenTree/common/tasks.py Refactors old notes image cleanup task for new schema; uses storage existence checks.
src/backend/InvenTree/common/serializers.py Adds Note + InstanceInfo serializers; refactors permission checks into shared helpers.
src/backend/InvenTree/common/models.py Adds Note model + new NotesImage FK; adds cleanup + sanitization behavior.
src/backend/InvenTree/common/migrations/0052_remove_notesimage_model_id_and_more.py Removes legacy NotesImage model_type/model_id fields; enforces FK to Note.
src/backend/InvenTree/common/migrations/0051_auto_20260525_0956.py Data migration: converts markdown notes to HTML notes and links images.
src/backend/InvenTree/common/migrations/0050_note.py Introduces Note model and initial NotesImage FK.
src/backend/InvenTree/common/migrations/0024_notesimage_model_id_notesimage_model_type.py Removes legacy validator reference from historical migration.
src/backend/InvenTree/common/api.py Adds Note endpoints + instance-info endpoint; restructures notes image API and filtering.
src/backend/InvenTree/common/admin.py Registers Note admin UI.
src/backend/InvenTree/build/test_api.py Adds build duplication note-copy tests; adjusts benchmark tolerance.
src/backend/InvenTree/build/serializers.py Removes legacy notes serializer mixin; adds copy-notes duplication support.
src/backend/InvenTree/build/models.py Switches Build to InvenTreeNoteMixin.
src/backend/InvenTree/build/migrations/0060_remove_build_notes.py Removes legacy notes field from Build.
src/backend/InvenTree/build/fixtures/build.yaml Removes legacy notes fixture fields.
docs/mkdocs.yml Adds Notes concept page to docs nav.
docs/docs/report/helpers.md Documents {% note %} / {% note_instance %} tags and markdown guidance changes.
docs/docs/plugins/develop.md Fixes formatting/typo in docs list item.
docs/docs/part/views.md Updates part notes docs to point to new notes concept page.
docs/docs/manufacturing/build.md Updates build notes docs to point to new notes concept page.
docs/docs/concepts/notes.md Adds full Notes concept documentation (multi-note, primary note, templates, editor).
CHANGELOG.md Adds breaking-change entry describing notes refactor and new API endpoint.
.github/workflows/import_export.yaml Updates dataset setup command (currently branch-pinned).
.github/workflows/frontend.yaml Updates dataset setup command (currently branch-pinned).
Suppressed comments (1)

.github/workflows/frontend.yaml:222

  • This workflow also uses invoke dev.setup-test -iv -b multi-note with a TODO. Before merge, CI should run against the standard dataset setup without relying on a temporary branch override.
      - name: Set up test data
        run: |
          invoke dev.setup-test -iv -b multi-note # TODO: Fix this before merging
          invoke int.rebuild-thumbnails

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 137 to 140
- name: Set up test data
run: |
invoke dev.setup-test -iv
invoke dev.setup-test -iv -b multi-note # TODO: Fix this before merging
invoke int.rebuild-thumbnails
Comment thread .github/workflows/import_export.yaml Resolved
@SchrodingersGat
SchrodingersGat merged commit 02da01d into inventree:master Aug 31, 2026
47 checks passed
@SchrodingersGat
SchrodingersGat deleted the block-notes branch August 31, 2026 06:46
adityakrmishra added a commit to adityakrmishra/InvenTree that referenced this pull request Aug 31, 2026
- Resolved api_version.py: bumped to v538, integrated Notes refactor (v537) and SCIM (v536) entries

- Resolved report/tests.py: combined RepairOrder and Note imports

- Fixed RepairOrderSerializer: removed deprecated NotesFieldMixin (removed by upstream Notes refactor PR inventree#11971)
adityakrmishra added a commit to adityakrmishra/InvenTree that referenced this pull request Aug 31, 2026
- Remove deprecated NotesFieldMixin from RepairOrderSerializer (removed by upstream Notes refactor PR inventree#11971)

- Update pui_repair.spec.ts: navigate to manufacturing/index/repairorders (table moved from sales)

- Update pui_repair.spec.ts: fill required part field during RepairOrder creation
@SchrodingersGat SchrodingersGat mentioned this pull request Sep 7, 2026
SchrodingersGat added a commit to inventree/inventree-app that referenced this pull request Sep 11, 2026
* Implement multi-note support

Ref: inventree/InvenTree#11971

* Bump iOS target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API breaking Indicates a major update or change which breaks compatibility feature full-run Always do a full QC CI run migration Data or schema migrations refactor User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notes Improvements

4 participants