mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-22 14:50:53 +00:00
Add "pack_units_native" field to company.SupplierPart model
This commit is contained in:
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
import InvenTree.fields
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
@ -15,4 +17,9 @@ class Migration(migrations.Migration):
|
|||||||
name='pack_units',
|
name='pack_units',
|
||||||
field=models.CharField(blank=True, help_text='Units of measure for this supplier part', max_length=25, verbose_name='Packaging Units'),
|
field=models.CharField(blank=True, help_text='Units of measure for this supplier part', max_length=25, verbose_name='Packaging Units'),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='pack_units_native',
|
||||||
|
field=InvenTree.fields.RoundingDecimalField(decimal_places=10, default=1, max_digits=20, null=True),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -13,7 +13,9 @@ def update_supplier_part_units(apps, schema_editor):
|
|||||||
supplier_parts = SupplierPart.objects.all()
|
supplier_parts = SupplierPart.objects.all()
|
||||||
|
|
||||||
for sp in supplier_parts:
|
for sp in supplier_parts:
|
||||||
sp.pack_units = str(normalize(sp.pack_size))
|
pack_size = normalize(sp.pack_size)
|
||||||
|
sp.pack_units = str(pack_size)
|
||||||
|
sp.pack_units_native = pack_size
|
||||||
sp.save()
|
sp.save()
|
||||||
|
|
||||||
if supplier_parts.count() > 0:
|
if supplier_parts.count() > 0:
|
||||||
@ -24,6 +26,7 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('company', '0059_supplierpart_pack_units'),
|
('company', '0059_supplierpart_pack_units'),
|
||||||
|
('part', '0111_auto_20230521_1350'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
@ -26,7 +26,7 @@ import InvenTree.ready
|
|||||||
import InvenTree.tasks
|
import InvenTree.tasks
|
||||||
import InvenTree.validators
|
import InvenTree.validators
|
||||||
from common.settings import currency_code_default
|
from common.settings import currency_code_default
|
||||||
from InvenTree.fields import InvenTreeURLField
|
from InvenTree.fields import InvenTreeURLField, RoundingDecimalField
|
||||||
from InvenTree.models import (InvenTreeAttachment, InvenTreeBarcodeMixin,
|
from InvenTree.models import (InvenTreeAttachment, InvenTreeBarcodeMixin,
|
||||||
InvenTreeNotesMixin, MetadataMixin)
|
InvenTreeNotesMixin, MetadataMixin)
|
||||||
from InvenTree.status_codes import PurchaseOrderStatus
|
from InvenTree.status_codes import PurchaseOrderStatus
|
||||||
@ -438,6 +438,7 @@ class SupplierPart(MetadataMixin, InvenTreeBarcodeMixin, common.models.MetaMixin
|
|||||||
lead_time: Supplier lead time
|
lead_time: Supplier lead time
|
||||||
packaging: packaging that the part is supplied in, e.g. "Reel"
|
packaging: packaging that the part is supplied in, e.g. "Reel"
|
||||||
pack_units: Quantity of item supplied in a single pack (e.g. 30ml in a single tube)
|
pack_units: Quantity of item supplied in a single pack (e.g. 30ml in a single tube)
|
||||||
|
pack_units_native: Pack units, converted to "native" units of the referenced part
|
||||||
updated: Date that the SupplierPart was last updated
|
updated: Date that the SupplierPart was last updated
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -578,6 +579,11 @@ class SupplierPart(MetadataMixin, InvenTreeBarcodeMixin, common.models.MetaMixin
|
|||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pack_units_native = RoundingDecimalField(
|
||||||
|
max_digits=20, decimal_places=10, default=1,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
multiple = models.PositiveIntegerField(default=1, validators=[MinValueValidator(1)], verbose_name=_('multiple'), help_text=_('Order multiple'))
|
multiple = models.PositiveIntegerField(default=1, validators=[MinValueValidator(1)], verbose_name=_('multiple'), help_text=_('Order multiple'))
|
||||||
|
|
||||||
# TODO - Reimplement lead-time as a charfield with special validation (pattern matching).
|
# TODO - Reimplement lead-time as a charfield with special validation (pattern matching).
|
||||||
|
Reference in New Issue
Block a user