mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Renamed related name "owned_parts" to "installed_parts"
This commit is contained in:
parent
a3f59d8115
commit
97b35d9269
19
InvenTree/stock/migrations/0051_auto_20200928_0928.py
Normal file
19
InvenTree/stock/migrations/0051_auto_20200928_0928.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2020-09-28 09:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('stock', '0050_auto_20200821_1403'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='stockitem',
|
||||||
|
name='belongs_to',
|
||||||
|
field=models.ForeignKey(blank=True, help_text='Is this item installed in another item?', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='installed_parts', to='stock.StockItem', verbose_name='Installed In'),
|
||||||
|
),
|
||||||
|
]
|
@ -341,7 +341,7 @@ class StockItem(MPTTModel):
|
|||||||
'self',
|
'self',
|
||||||
verbose_name=_('Installed In'),
|
verbose_name=_('Installed In'),
|
||||||
on_delete=models.DO_NOTHING,
|
on_delete=models.DO_NOTHING,
|
||||||
related_name='owned_parts', blank=True, null=True,
|
related_name='installed_parts', blank=True, null=True,
|
||||||
help_text=_('Is this item installed in another item?')
|
help_text=_('Is this item installed in another item?')
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -585,6 +585,20 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def installedItemCount(self):
|
||||||
|
"""
|
||||||
|
Return the number of stock items installed inside this one.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.installed_parts.count()
|
||||||
|
|
||||||
|
def hasInstalledItems(self):
|
||||||
|
"""
|
||||||
|
Returns true if this stock item has other stock items installed in it.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.installedItemCount() > 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def children(self):
|
def children(self):
|
||||||
""" Return a list of the child items which have been split from this stock item """
|
""" Return a list of the child items which have been split from this stock item """
|
||||||
|
Loading…
Reference in New Issue
Block a user