Repository navigation
[Refactor] Notes - #11971
[Refactor] Notes#11971
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
|
@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 Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
I think the general idea is very good; a few points/ideas:
I like blocknote as a choice, the OpenProject and a bunch of other EU sovereign gov cloud products use it. Things i am unsure about:
|
|
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. |
All markdown features should be forward-compatible. This will be fully tested. I don't want to lose any of my notes, either.
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. |
- Find any NoteImage items which do not link to a model - Try to associate them with an existing note
|
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. |
There was a problem hiding this comment.
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
Notemodel + migrations to move legacy notes/images, replaceInvenTreeNotesMixinwithInvenTreeNoteMixin, update duplication + search + reports accordingly. - Frontend: new rich-text notes UI (including templates), new
useInstanceInfohook + 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-notewith 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.
| - 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 |
- 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)
- 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
* Implement multi-note support Ref: inventree/InvenTree#11971 * Bump iOS target
Example Screenshots
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:
Cons:
Tasks
Ideas for future work