mirror of
				https://github.com/inventree/inventree-docs.git
				synced 2025-11-04 06:25:39 +00:00 
			
		
		
		
	Merge pull request #81 from SergeoLacruz/master
Added examples for stock locations
This commit is contained in:
		@@ -118,16 +118,40 @@ WeightTemplate = ParameterTemplate.create(api, { 'name' : 'Weight', 'units' : 'k
 | 
			
		||||
## Now we create the parameters
 | 
			
		||||
ParameterLength = Parameter.create(api, { 'part': couch.pk, 'template': LengthTemplate.pk, 'data' : 2 })
 | 
			
		||||
ParameterWeight = Parameter.create(api, { 'part': couch.pk, 'template': WeightTemplate.pk, 'data' : 60 })
 | 
			
		||||
 | 
			
		||||
## Create a new StockItem
 | 
			
		||||
item = StockItem.create(api, {
 | 
			
		||||
    'part': couch.pk,
 | 
			
		||||
    'quantity': 5,
 | 
			
		||||
    'notes': 'A stack of couches',
 | 
			
		||||
    'location': 10,  ## PK of a StockLocation already in the database...
 | 
			
		||||
})
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
#### Adding a location to the sofa
 | 
			
		||||
 | 
			
		||||
If we have several sofas on stock we need to know there we have stored them. So let’s add stock locations to the part. Stock locations can be organized in a hierarchical manner e.g. boxes in shelves in aisles in rooms. So each location can have a parent. Let’s assume we have 10 sofas in box 12 and 3 sofas in box 13 located in shelve 43 aisle 3. First we have to create the locations, afterwards we can put the sofas inside.
 | 
			
		||||
 | 
			
		||||
```python
 | 
			
		||||
 | 
			
		||||
from inventree.stock import StockLocation
 | 
			
		||||
from inventree.stock import StockItem
 | 
			
		||||
 | 
			
		||||
...
 | 
			
		||||
 | 
			
		||||
## Create the stock locations. Leave the parent empty for top level hierarchy
 | 
			
		||||
Aisle3 = StockLocation.create(api, {'name':'Aisle 3','description':'Aisle for sofas','parent':''})
 | 
			
		||||
Shelve43 = StockLocation.create(api, {'name':'Shelve 43','description':'Shelve for sofas','parent':Aisle3.pk})
 | 
			
		||||
Box12 = StockLocation.create(api, {'name':'Box 12','description':'green box','parent':Shelve43.pk})
 | 
			
		||||
Box13 = StockLocation.create(api, {'name':'Box 13','description':'red box','parent':Shelve43.pk})
 | 
			
		||||
 | 
			
		||||
## Now fill them with items
 | 
			
		||||
Id1 = StockItem.create(api, { 'part': sofa.pk, 'quantity': 10, 'notes': 'new ones', 'location': Box12.pk, ‘status’:10 })
 | 
			
		||||
Id2 = StockItem.create(api, { 'part': sofa.pk, 'quantity': 3, 'notes': 'old ones', 'location': Box13.pk, ‘status’:55 })
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
Please recognize the different status flags. 10 means OK, 55 means damaged. We have the following choices:
 | 
			
		||||
 | 
			
		||||
* 10: OK
 | 
			
		||||
* 50: Attention needed
 | 
			
		||||
* 55: Damaged
 | 
			
		||||
* 60: Destroyed
 | 
			
		||||
* 65: Rejected
 | 
			
		||||
* 70: Lost
 | 
			
		||||
* 85: Returned
 | 
			
		||||
 | 
			
		||||
#### Adding manufacturers and supplier
 | 
			
		||||
 | 
			
		||||
We can add manufacturers and suppliers to parts. If we add a manufacturer, a supplier is also mandatory. So we first need to create two companies, ACME (manufacturer) and X-Store (supplier).
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user