2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Support image uploads in the "notes" markdown fields (#4615)

* Support image uploads in the "notes" markdown fields

- Implemented using the existing EasyMDE library
- Copy / paste support
- Drag / drop support

* Remove debug message

* Updated API version

* Better UX when saving notes

* Pin PIP version (for testing)

* Bug fixes

- Fix typo
- Use correct serializer type

* Add unit testing

* Update role permissions

* Typo fix

* Update migration file

* Adds a notes mixin class to be used for refactoring

* Refactor existing models with notes to use the new mixin

* Add helper function for finding all model types with a certain mixin

* Refactor barcode plugin to use new method

* Typo fix

* Add daily task to delete old / unused notes

* Bug fix for barcode refactoring

* Add unit testing for function
This commit is contained in:
Oliver
2023-04-19 13:08:26 +10:00
committed by GitHub
parent 2623c22b7e
commit 5cd74c4190
24 changed files with 441 additions and 63 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 3.2.18 on 2023-04-19 00:37
import InvenTree.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('stock', '0096_auto_20230330_1121'),
]
operations = [
migrations.AlterField(
model_name='stockitem',
name='notes',
field=InvenTree.fields.InvenTreeNotesField(blank=True, help_text='Markdown notes (optional)', max_length=50000, null=True, verbose_name='Notes'),
),
]

View File

@ -29,10 +29,9 @@ import InvenTree.tasks
import label.models
import report.models
from company import models as CompanyModels
from InvenTree.fields import (InvenTreeModelMoneyField, InvenTreeNotesField,
InvenTreeURLField)
from InvenTree.fields import InvenTreeModelMoneyField, InvenTreeURLField
from InvenTree.models import (InvenTreeAttachment, InvenTreeBarcodeMixin,
InvenTreeTree, extract_int)
InvenTreeNotesMixin, InvenTreeTree, extract_int)
from InvenTree.status_codes import (SalesOrderStatus, StockHistoryCode,
StockStatus)
from part import models as PartModels
@ -279,7 +278,7 @@ def default_delete_on_deplete():
return True
class StockItem(InvenTreeBarcodeMixin, MetadataMixin, common.models.MetaMixin, MPTTModel):
class StockItem(InvenTreeBarcodeMixin, InvenTreeNotesMixin, MetadataMixin, common.models.MetaMixin, MPTTModel):
"""A StockItem object represents a quantity of physical instances of a part.
Attributes:
@ -800,8 +799,6 @@ class StockItem(InvenTreeBarcodeMixin, MetadataMixin, common.models.MetaMixin, M
"""Return the text representation of the status field"""
return StockStatus.text(self.status)
notes = InvenTreeNotesField(help_text=_('Stock Item Notes'))
purchase_price = InvenTreeModelMoneyField(
max_digits=19,
decimal_places=6,