diff --git a/OneSila/contacts/schema/types/types.py b/OneSila/contacts/schema/types/types.py index 26c56d03..c276cb4d 100644 --- a/OneSila/contacts/schema/types/types.py +++ b/OneSila/contacts/schema/types/types.py @@ -18,6 +18,12 @@ class CompanyType(relay.Node, GetQuerysetMultiTenantMixin): currency: Optional[CurrencyType] person_set: List[Annotated['PersonType', lazy("contacts.schema.types.types")]] + @field() + def country(self, info) -> str | None: + try: + return InvoiceAddress.objects.filter_multi_tenant(self.multi_tenant_company).filter(company=self).first().get_country_display() + except Exception: + return None @type(Supplier, filters=SupplierFilter, order=SupplierOrder, pagination=True, fields="__all__") class SupplierType(relay.Node, GetQuerysetMultiTenantMixin): diff --git a/OneSila/eancodes/schema/types/types.py b/OneSila/eancodes/schema/types/types.py index 2b317c52..37b4bf79 100644 --- a/OneSila/eancodes/schema/types/types.py +++ b/OneSila/eancodes/schema/types/types.py @@ -3,10 +3,11 @@ from typing import List from eancodes.models import EanCode +from products.schema.types.filters import ProductFilter from .filters import EanCodeFilter from .ordering import EanCodeOrder @type(EanCode, filters=EanCodeFilter, order=EanCodeOrder, pagination=True, fields="__all__") class EanCodeType(relay.Node, GetQuerysetMultiTenantMixin): - pass + product: ProductFilter | None diff --git a/OneSila/orders/schema/types/types.py b/OneSila/orders/schema/types/types.py index 66ded908..13ce54d0 100644 --- a/OneSila/orders/schema/types/types.py +++ b/OneSila/orders/schema/types/types.py @@ -22,6 +22,13 @@ class OrderType(relay.Node, GetQuerysetMultiTenantMixin): def total_value(self) -> str | None: return self.total_value_currency + @field() + def country(self, info) -> str | None: + try: + return self.shipping_address.get_country_display() + except Exception: + return None + @type(OrderItem, filters=OrderItemFilter, order=OrderItemOrder, pagination=True, fields="__all__") class OrderItemType(relay.Node, GetQuerysetMultiTenantMixin): diff --git a/OneSila/purchasing/schema/types/types.py b/OneSila/purchasing/schema/types/types.py index c7afea4c..d6a0bbbb 100644 --- a/OneSila/purchasing/schema/types/types.py +++ b/OneSila/purchasing/schema/types/types.py @@ -23,6 +23,13 @@ class PurchaseOrderType(relay.Node, GetQuerysetMultiTenantMixin): def total_value(self) -> str | None: return self.total_value + @field() + def country(self, info) -> str | None: + try: + return self.invoice_address.get_country_display() + except Exception: + return None + @type(PurchaseOrderItem, filters=PurchaseOrderItemFilter, order=PurchaseOrderItemOrder, pagination=True, fields="__all__") class PurchaseOrderItemType(relay.Node, GetQuerysetMultiTenantMixin):