added get_inventory_logs_of_type() to Asset
This commit is contained in:
@@ -23,7 +23,7 @@ def init_api():
|
||||
client_secret = client_secret
|
||||
)
|
||||
break
|
||||
except ConnectionError:
|
||||
except:
|
||||
print("Fehler bei Verbindung mit Server (wahrscheinlich DuckDns) probiere erneut...")
|
||||
|
||||
oauth = OAuth2(client_id=client_id, client=client, token=token)
|
||||
|
||||
@@ -23,6 +23,19 @@ class Asset(jsonapi_requests.orm.ApiModel):
|
||||
break;
|
||||
return related
|
||||
|
||||
def get_inventory_logs_of_type(self, type):
|
||||
if not issubclass(type, Log.Log):
|
||||
raise ValueError("type specified is not a type of log use for example: get_logs_of_type(Log.Harvest)")
|
||||
logs = type.get_list()
|
||||
related = []
|
||||
for log in logs:
|
||||
for quantity in log.quantities:
|
||||
if quantity.inventory_asset:
|
||||
if quantity.inventory_asset.id == self.id:
|
||||
related.append(log)
|
||||
break;
|
||||
return related
|
||||
|
||||
class Land(Asset):
|
||||
class Meta(Asset.Meta):
|
||||
name = 'land'
|
||||
|
||||
4
test.py
4
test.py
@@ -1,5 +1,5 @@
|
||||
import neofarm.lib as neo
|
||||
|
||||
if __name__ == "__main__":
|
||||
log = neo.Log.Seeding.get_list()[1]
|
||||
print(log.notes)
|
||||
log = neo.Log.Input.from_id("d2e78314-730c-47ae-a0b4-aff42025475e")
|
||||
print(log.quantities[0].inventory_asset.get_inventory_logs_of_type(neo.Log.Purchase)[0].name)
|
||||
Reference in New Issue
Block a user