odoogap / vuestorefront

30 stars 25 forks source link

Qty error in query #4

Open gianmichelesiano opened 2 years ago

gianmichelesiano commented 2 years ago

When I try to execute a product query I have this problem:

"message": "'product.template' object has no attribute 'free_qty'", v.14 query { product (id: 37) { name, availableThreshold, isInStock, qty } }

vldmir commented 2 years ago

@gianmichelesiano did you manage to fix it? I have the same issue. Please let me know

gianmichelesiano commented 2 years ago

@vldmir I have just put error handling in : .\graphql_vuestorefront\schemas\objects.py

` def resolve_status(self, info): if hasattr(self, 'free_qty') and self.free_qty > 0: return self.free_qty else: return 0

def resolve_is_in_stock(self, info): if hasattr(self, 'free_qty'): return bool(self.free_qty > 0) else: return False

def resolve_qty(self, info): if hasattr(self, 'free_qty'): return self.free_qty else: return 0`