inventree / inventree-python

Python library for communication with inventree via API
https://docs.inventree.org/en/latest/api/python/python/
MIT License
27 stars 35 forks source link

Add support for more recent API endpoints #90

Closed SchrodingersGat closed 1 year ago

SchrodingersGat commented 2 years ago

Many database actions have now been migrated to the API:

https://github.com/inventree/InvenTree/issues/2253

Some (many) of these could now be supported directly by the Python bindings:

miggland commented 2 years ago

I'm working on a PR for these:

The testing is proving to be a bit finicky, it's hard to know what the status is, especially when running the tests several times consecutively.

Also, the names of the functions/API endpoints is not consistent. I'm not working on the 'complete' API endpoint, as this is for completing outputs, not the total order - which is called finish.

matmair commented 2 years ago

@miggland if you have suggestions for better names we are very open for that. The easier to understand the better as a German would say ;-)

SchrodingersGat commented 2 years ago

The testing is proving to be a bit finicky, it's hard to know what the status is, especially when running the tests several times consecutively.

Try to ensure that each unit test can run "atomically" - i.e. set the state of the items under test to a known state at the start of the test. This way, other tests won't get in the way.

e.g. here : https://github.com/inventree/inventree-python/blob/a5c4fd04c4ee73fee1d60401747d9c2c43ce0680/test/test_part.py#L121

The unit test ensures that the new categories created are unique, by not hard-coding the names of the categories.

miggland commented 2 years ago

@miggland if you have suggestions for better names we are very open for that. The easier to understand the better as a German would say ;-)

There's only a few which have different names, as below. Changing these would make things more consistent. But, it would also break things..

Action Current API name Suggestion
Cancel build order cancel
Complete build order finish complete
Complete build output complete complete-output
Cancel purchase order cancel
Complete purchase order complete
Issue purchase order issue
Cancel sales order cancel
Complete sales order complete
Ship sales order ship complete
matmair commented 2 years ago

@miggland great suggestions here. The collisions are hard to solve - would need to be a major release for sure. @SchrodingersGat would you be interested in a renaming initiative or would you prefer to do other stuff first? I know we are spread thin.

SchrodingersGat commented 2 years ago

@miggland I'd rather not rename any API endpoints, as this will break existing code. We can improve the documentation around the functionality, but I think we are stuck with them.

Note that you can call the python functions something more sensible, and just point to the poorly-named endpoints

miggland commented 2 years ago

Currently, I have added aliases, eg so that 'finish' and 'complete' on a build-order does the same thing. Once I get around to it I'll have another go at the tests (as you suggest, I'll have to make them atomic - just that requires adding an order, parts, assigning, shipping, and then completing the order..