mirror of
				https://github.com/inventree/inventree-docs.git
				synced 2025-10-31 12:55:37 +00:00 
			
		
		
		
	Update python.md
This commit is contained in:
		| @@ -118,16 +118,38 @@ 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 | ||||
| Aisle3 = StockLocation.create(api, {'name':'Aisle','description':'Aisle for sofas','parent':''}) | ||||
| Shelve43 = StockLocation.create(api, {'name':'Shelve43','description':'Shelve for sofas','parent':Aisle2.pk}) | ||||
| Box12 = StockLocation.create(api, {'name':'Box12','description':'green box','parent':shelve43.pk}) | ||||
| Box13 = StockLocation.create(api, {'name':'Box13','description':'red box','parent':shelve43.pk}) | ||||
|  | ||||
| ## Fill them with items | ||||
| Id1 = StockItem.create(api, { 'part': sofa.pk, 'quantity': 10, 'notes': 'new ones', 'location': Box12.pk, ‘status’:10 }) | ||||
| Id1 = StockItem.create(api, { 'part': sofa.pk, 'quantity': 3, 'notes': 'new 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