2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10: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,34 @@
# 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 = [
('order', '0090_auto_20230412_1752'),
]
operations = [
migrations.AlterField(
model_name='purchaseorder',
name='notes',
field=InvenTree.fields.InvenTreeNotesField(blank=True, help_text='Markdown notes (optional)', max_length=50000, null=True, verbose_name='Notes'),
),
migrations.AlterField(
model_name='returnorder',
name='notes',
field=InvenTree.fields.InvenTreeNotesField(blank=True, help_text='Markdown notes (optional)', max_length=50000, null=True, verbose_name='Notes'),
),
migrations.AlterField(
model_name='salesorder',
name='notes',
field=InvenTree.fields.InvenTreeNotesField(blank=True, help_text='Markdown notes (optional)', max_length=50000, null=True, verbose_name='Notes'),
),
migrations.AlterField(
model_name='salesordershipment',
name='notes',
field=InvenTree.fields.InvenTreeNotesField(blank=True, help_text='Markdown notes (optional)', max_length=50000, null=True, verbose_name='Notes'),
),
]

View File

@ -32,11 +32,11 @@ from common.notifications import InvenTreeNotificationBodies
from common.settings import currency_code_default
from company.models import Company, Contact, SupplierPart
from InvenTree.exceptions import log_error
from InvenTree.fields import (InvenTreeModelMoneyField, InvenTreeNotesField,
InvenTreeURLField, RoundingDecimalField)
from InvenTree.fields import (InvenTreeModelMoneyField, InvenTreeURLField,
RoundingDecimalField)
from InvenTree.helpers import decimal2string, getSetting, notify_responsible
from InvenTree.models import (InvenTreeAttachment, InvenTreeBarcodeMixin,
ReferenceIndexingMixin)
InvenTreeNotesMixin, ReferenceIndexingMixin)
from InvenTree.status_codes import (PurchaseOrderStatus, ReturnOrderLineStatus,
ReturnOrderStatus, SalesOrderStatus,
StockHistoryCode, StockStatus)
@ -131,7 +131,7 @@ class TotalPriceMixin(models.Model):
return total
class Order(InvenTreeBarcodeMixin, MetadataMixin, ReferenceIndexingMixin):
class Order(InvenTreeBarcodeMixin, InvenTreeNotesMixin, MetadataMixin, ReferenceIndexingMixin):
"""Abstract model for an order.
Instances of this class:
@ -234,8 +234,6 @@ class Order(InvenTreeBarcodeMixin, MetadataMixin, ReferenceIndexingMixin):
related_name='+',
)
notes = InvenTreeNotesField(help_text=_('Order notes'))
@classmethod
def get_status_class(cls):
"""Return the enumeration class which represents the 'status' field for this model"""
@ -1330,7 +1328,7 @@ class SalesOrderLineItem(OrderLineItem):
return self.shipped >= self.quantity
class SalesOrderShipment(MetadataMixin, models.Model):
class SalesOrderShipment(InvenTreeNotesMixin, MetadataMixin, models.Model):
"""The SalesOrderShipment model represents a physical shipment made against a SalesOrder.
- Points to a single SalesOrder object
@ -1389,8 +1387,6 @@ class SalesOrderShipment(MetadataMixin, models.Model):
default='1',
)
notes = InvenTreeNotesField(help_text=_('Shipment notes'))
tracking_number = models.CharField(
max_length=100,
blank=True,