mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add PurchaseOrderAttachment model
- File attachment against PurchaseOrder
This commit is contained in:
parent
a661d7e1a6
commit
cc41752f9f
27
InvenTree/order/migrations/0016_purchaseorderattachment.py
Normal file
27
InvenTree/order/migrations/0016_purchaseorderattachment.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Generated by Django 2.2.9 on 2020-03-22 07:01
|
||||
|
||||
import InvenTree.models
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('order', '0015_auto_20200201_2346'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PurchaseOrderAttachment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('attachment', models.FileField(help_text='Select file to attach', upload_to=InvenTree.models.rename_attachment)),
|
||||
('comment', models.CharField(help_text='File comment', max_length=100)),
|
||||
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='order.PurchaseOrder')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
@ -14,6 +14,7 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
from markdownx.models import MarkdownxField
|
||||
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from stock.models import StockItem
|
||||
@ -21,6 +22,7 @@ from company.models import Company, SupplierPart
|
||||
|
||||
from InvenTree.helpers import decimal2string
|
||||
from InvenTree.status_codes import OrderStatus
|
||||
from InvenTree.models import InvenTreeAttachment
|
||||
|
||||
|
||||
class Order(models.Model):
|
||||
@ -239,6 +241,17 @@ class PurchaseOrder(Order):
|
||||
self.complete_order() # This will save the model
|
||||
|
||||
|
||||
class PurchaseOrderAttachment(InvenTreeAttachment):
|
||||
"""
|
||||
Model for storing file attachments against a PurchaseOrder object
|
||||
"""
|
||||
|
||||
def getSubdir(self):
|
||||
return os.path.join("po_files", str(self.order.id))
|
||||
|
||||
order = models.ForeignKey(PurchaseOrder, on_delete=models.CASCADE, related_name="attachments")
|
||||
|
||||
|
||||
class OrderLineItem(models.Model):
|
||||
""" Abstract model for an order line item
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user