mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Create initial migration file
This commit is contained in:
parent
5e5fc35655
commit
ff33cc43bd
41
InvenTree/stock/migrations/0064_auto_20210621_1724.py
Normal file
41
InvenTree/stock/migrations/0064_auto_20210621_1724.py
Normal file
@ -0,0 +1,41 @@
|
||||
# Generated by Django 3.2.4 on 2021-06-21 07:24
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def extract_purchase_price(apps, schema_editor):
|
||||
"""
|
||||
Find instances of StockItem which do *not* have a purchase price set,
|
||||
but which point to a PurchaseOrder where there *is* a purchase price set.
|
||||
|
||||
Then, assign *that* purchase price to original StockItem.
|
||||
|
||||
This is to address an issue where older versions of InvenTree
|
||||
did not correctly copy purchase price information cross to the StockItem objects.
|
||||
|
||||
Current InvenTree version (as of 2021-06-21) copy this information across correctly,
|
||||
so this one-time data migration should suffice.
|
||||
"""
|
||||
|
||||
# Required database models
|
||||
StockItem = apps.get_model('stock', 'stockitem')
|
||||
PurchaseOrder = apps.get_model('order', 'purchaseorder')
|
||||
Part = apps.get_model('part', 'part')
|
||||
|
||||
|
||||
def reverse_operation(apps, schema_editor):
|
||||
"""
|
||||
DO NOTHING!
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0063_auto_20210511_2343'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(extract_purchase_price, reverse_code=reverse_operation)
|
||||
]
|
Loading…
Reference in New Issue
Block a user