entire v3 datamodel orm NEXT: test orm

This commit is contained in:
2024-11-01 14:47:03 +01:00
parent 4bfebf2f61
commit ae1156bd6c
6 changed files with 213 additions and 167 deletions

31
neofarm/orm/quantity.py Normal file
View File

@@ -0,0 +1,31 @@
import jsonapi_requests
class Quantity(jsonapi_requests.orm.ApiModel):
class Meta:
type = 'quantity'
api = api
@classmethod
def get_type_and_path(cls, name):
return (f"{cls.type}{api_type_spatrator}{name}", f"{cls.path}{api_path_separator}{name}")
measure = jsonapi_requests.orm.AttributeField('measure')
measure = jsonapi_requests.orm.AttributeField('value.decimal')
units = jsonapi_requests.orm.RelationFieldField('units')
inventory_adjustment = jsonapi_requests.orm.AttributeField('inventory_adjustment')
inventory_asset = jsonapi_requests.orm.RelationFieldField('inventory_asset')
class Standard(Quantity):
class Meta(Quantity.Meta):
name = 'standard'
type, path = Asset.Meta.get_type_and_path(name)
class Price(Quantity):
class Meta(Quantity.Meta):
name = 'price'
type, path = Asset.Meta.get_type_and_path(name)
unit_price = jsonapi_requests.orm.AttributeField('unit_price.decimal')
total_price = jsonapi_requests.orm.AttributeField('total_price.decimal')
class Material(Quantity):
class Meta(Quantity.Meta):
name = 'material'
type, path = Asset.Meta.get_type_and_path(name)
unit_price = jsonapi_requests.orm.RelationField('material_type')