From b4af0702af7f124a94c076368c5a759cf47d9d3d Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 27 Jan 2022 19:36:38 +0100 Subject: [PATCH 1/6] Update python.md --- docs/extend/python.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/extend/python.md b/docs/extend/python.md index 78cdf69..e1d357a 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -198,3 +198,12 @@ SupplierPart.create(api,{ ``` Supplier and manufacturer are added with just one command. The SKU is the code under which the couch is listed in the store. + +#### Add the user manual or other documents +We have the possibility to add documents to the part. We can use pdf for documents but also other files like 3D drawings or pictures. To do so we add the following commands: + +```python +blabla + +``` +Thats it. From 12442039817f6991ef5617fae0cc2ed1ad1c76ca Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 27 Jan 2022 19:49:23 +0100 Subject: [PATCH 2/6] Update python.md --- docs/extend/python.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/extend/python.md b/docs/extend/python.md index e1d357a..51c9949 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -92,7 +92,7 @@ from inventree.base import Parameter from inventree.base import ParameterTemplate ## Create a new PartCategory object, -## underneath the existing category with pk 7 +## underneath the existing category with pk 7. Leave the parent empty fpr a top level category furniture = PartCategory.create(api, { 'name': 'Furniture', 'description': 'Chairs, tables, etc', @@ -109,20 +109,27 @@ couch = Part.create(api, { 'virtual': False, ## Note - You do not have to fill out *all* fields }) +``` +#### Adding parameters to the sofa +Each can have multiple parameters like added like resistance, voltage or capacitance. For the sofa length and weight make sense. Each parameter has a parameter template that combines the parameter name with a unit. So we first have to create the parameters: -## Before we can add parameters to the couch, we neeed to create the parameter templates -## These parameter templates need to be defined only once and can be used for all other parts. +```python LengthTemplate = ParameterTemplate.create(api, { 'name' : 'Length', 'units' : 'Meters' }) WeightTemplate = ParameterTemplate.create(api, { 'name' : 'Weight', 'units' : 'kg' }) +``` +These parameter templates need to be defined only once and can be used for all other parts. Now add parameter values to the sofa -## Now we create the parameters +```python ParameterLength = Parameter.create(api, { 'part': couch.pk, 'template': LengthTemplate.pk, 'data' : 2 }) ParameterWeight = Parameter.create(api, { 'part': couch.pk, 'template': WeightTemplate.pk, 'data' : 60 }) +``` +Lets finally add a picture -## Add a picture to the part +```python couch.upload_image('my_nice_couch.jpg') ``` + #### 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. From b5b8580bc127caed1a5c89e443c861536fb289ff Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 27 Jan 2022 19:55:08 +0100 Subject: [PATCH 3/6] Update python.md --- docs/extend/python.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/extend/python.md b/docs/extend/python.md index 51c9949..8f99e45 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -88,8 +88,6 @@ stock_item.uploadTestResult("Firmware", True, value="0x12345678", attachment="de ```python from inventree.part import Part, PartCategory from inventree.stock import StockItem -from inventree.base import Parameter -from inventree.base import ParameterTemplate ## Create a new PartCategory object, ## underneath the existing category with pk 7. Leave the parent empty fpr a top level category @@ -111,19 +109,19 @@ couch = Part.create(api, { }) ``` #### Adding parameters to the sofa -Each can have multiple parameters like added like resistance, voltage or capacitance. For the sofa length and weight make sense. Each parameter has a parameter template that combines the parameter name with a unit. So we first have to create the parameters: +Each part can have multiple parameters like resistance, voltage or capacitance. For the sofa length and weight make sense. Each parameter has a parameter template that combines the parameter name with a unit. So we first have to create the parameters and afterwards add the parameter values to the sofa. ```python +from inventree.base import Parameter +from inventree.base import ParameterTemplate + LengthTemplate = ParameterTemplate.create(api, { 'name' : 'Length', 'units' : 'Meters' }) WeightTemplate = ParameterTemplate.create(api, { 'name' : 'Weight', 'units' : 'kg' }) -``` -These parameter templates need to be defined only once and can be used for all other parts. Now add parameter values to the sofa -```python ParameterLength = Parameter.create(api, { 'part': couch.pk, 'template': LengthTemplate.pk, 'data' : 2 }) ParameterWeight = Parameter.create(api, { 'part': couch.pk, 'template': WeightTemplate.pk, 'data' : 60 }) ``` -Lets finally add a picture +These parameter templates need to be defined only once and can be used for all other parts. Lets finally add a picture. ```python couch.upload_image('my_nice_couch.jpg') From 06c6b490fea4b5f4adf9f2960f3cf95667a818e2 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 27 Jan 2022 19:56:07 +0100 Subject: [PATCH 4/6] 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 8f99e45..242aefb 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -109,7 +109,7 @@ couch = Part.create(api, { }) ``` #### Adding parameters to the sofa -Each part can have multiple parameters like resistance, voltage or capacitance. For the sofa length and weight make sense. Each parameter has a parameter template that combines the parameter name with a unit. So we first have to create the parameters and afterwards add the parameter values to the sofa. +Each part can have multiple parameters like resistance, voltage or capacitance. For the sofa length and weight make sense. Each parameter has a parameter template that combines the parameter name with a unit. So we first have to create the parameter templates and afterwards add the parameter values to the sofa. ```python from inventree.base import Parameter From 841899a9802719f6fc8996d2bd9aa6cd875f394b Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 27 Jan 2022 20:37:49 +0100 Subject: [PATCH 5/6] Update python.md --- docs/extend/python.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/extend/python.md b/docs/extend/python.md index 242aefb..1588f65 100644 --- a/docs/extend/python.md +++ b/docs/extend/python.md @@ -204,11 +204,13 @@ SupplierPart.create(api,{ Supplier and manufacturer are added with just one command. The SKU is the code under which the couch is listed in the store. -#### Add the user manual or other documents +#### Add a datasheet or other documents We have the possibility to add documents to the part. We can use pdf for documents but also other files like 3D drawings or pictures. To do so we add the following commands: ```python -blabla +from inventree.part import PartAttachment +PartAttachment.upload_attachment(api, pk, **{'comment':'Datasheet', 'attachment':'manual.pdf'} ) +PartAttachment.upload_attachment(api, pk, **{'comment':'Drawing', 'attachment':'sofa.dxf'} ) ``` -Thats it. +Here pk is the primary key of the part where the attachment will be added, comment is a name of the attachment that can be freely chosen and attachment is a file that must exist.