From 652f325d1817bb5862dd17f05d8bd89627d96369 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 11 Mar 2021 07:46:13 +0100 Subject: [PATCH 1/5] Update python.md --- docs/extend/python.md | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/extend/python.md b/docs/extend/python.md index 68b25c5..8ffb600 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -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). From 60a0c262551ce0cc0254644800dfcb1b3577283b Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 11 Mar 2021 07:50:07 +0100 Subject: [PATCH 2/5] Update python.md --- docs/extend/python.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/extend/python.md b/docs/extend/python.md index 8ffb600..486b75b 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -129,7 +129,7 @@ If we have several sofas on stock we need to know there we have stored them. So from inventree.stock import StockLocation from inventree.stock import StockItem -## Create the stock locations +## Create the stock locations. Leave the parent empty for top level hierarchy 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}) @@ -142,13 +142,13 @@ Id1 = StockItem.create(api, { 'part': sofa.pk, 'quantity': 3, 'notes': 'new ones ``` 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 +* 10 OK +* 50 Attention needed +* 55 Damaged +* 60 Destroyed +* 65 Rejected +* 70 Lost +* 85 Returned #### Adding manufacturers and supplier From 23501b9e2034d8936a518ab819fe27511fee1edc Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 11 Mar 2021 07:53:13 +0100 Subject: [PATCH 3/5] Update python.md --- docs/extend/python.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/extend/python.md b/docs/extend/python.md index 486b75b..d9f2f5b 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -130,14 +130,14 @@ 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','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}) +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}) -## Fill them with items +## Now 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 }) +Id2 = 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: From 49d567270b652d82db97aefced767305f3bcda28 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 11 Mar 2021 07:54:02 +0100 Subject: [PATCH 4/5] Update python.md --- docs/extend/python.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/extend/python.md b/docs/extend/python.md index d9f2f5b..2b33dfe 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -137,7 +137,7 @@ Box13 = StockLocation.create(api, {'name':'Box 13','description':'red box','pare ## 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': 'new ones', 'location': Box13.pk, ‘status’:55 }) +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: From 9a67f4f2b5c84c113b6f3622e4502c95b245a9ea Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 11 Mar 2021 08:00:10 +0100 Subject: [PATCH 5/5] Added example for stock locations How t o add stock locations and stock items --- docs/extend/python.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/extend/python.md b/docs/extend/python.md index 2b33dfe..be4a224 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -129,6 +129,8 @@ If we have several sofas on stock we need to know there we have stored them. So 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}) @@ -137,18 +139,18 @@ Box13 = StockLocation.create(api, {'name':'Box 13','description':'red box','pare ## 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 }) +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 +* 10: OK +* 50: Attention needed +* 55: Damaged +* 60: Destroyed +* 65: Rejected +* 70: Lost +* 85: Returned #### Adding manufacturers and supplier