diff --git a/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/OdooConstants.java b/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/OdooConstants.java index 88c30b2..df5e9cb 100644 --- a/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/OdooConstants.java +++ b/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/OdooConstants.java @@ -33,4 +33,6 @@ public class OdooConstants { public static final String MODEL_PRODUCT = "product.product"; public static final String MODEL_CURRENCY = "res.currency"; + + public static final String PRODUCT_TYPE_STORABLE = "product"; } diff --git a/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/model/Product.java b/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/model/Product.java index 03d5ead..50efe76 100644 --- a/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/model/Product.java +++ b/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/model/Product.java @@ -59,4 +59,7 @@ public class Product extends BaseOdooModel { @JsonProperty("currency_id") private Integer currencyId; + + @JsonProperty("type") + private String type; } diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/api/ProductService.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/api/ProductService.java index ad74284..2f7d378 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/api/ProductService.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/api/ProductService.java @@ -40,6 +40,11 @@ protected Product mapRowToResource(Row row) { product.setPublicPrice((Double) row.get("lst_price")); product.setStandardPrice((Double) row.get("standard_price")); + var type = row.get("type"); + if (type != null) { + product.setType((String) row.get("type")); + } + var active = row.get("active"); if (active != null) { product.setActive((boolean) row.get("active")); diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/inventoryItem/impl/InventoryItemServiceImpl.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/inventoryItem/impl/InventoryItemServiceImpl.java index 85e36b8..9450845 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/inventoryItem/impl/InventoryItemServiceImpl.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/inventoryItem/impl/InventoryItemServiceImpl.java @@ -60,6 +60,12 @@ public Optional getById(@Nonnull String id) { log.warn("Inventory Item with ID {} missing a Product", id); return Optional.empty(); } + + // Only return stockable products + if (product.get().getType() == null || !product.get().getType().equals(OdooConstants.PRODUCT_TYPE_STORABLE)) { + return Optional.empty(); + } + Map resourceMap = Map.of( OdooConstants.MODEL_PRODUCT, product.get(), OdooConstants.MODEL_EXTERNAL_IDENTIFIER, externalIdentifier.get()); @@ -78,7 +84,9 @@ public Bundle searchForInventoryItems(TokenAndListParam code) { Collection extIds = extIdService.getResIdsByNameAndModel(codes, OdooConstants.MODEL_PRODUCT); extIds.forEach(externalIdentifier -> { Optional product = productService.getById(String.valueOf(externalIdentifier.getResId())); - if (product.isPresent() && product.get().isActive()) { + if (product.isPresent() + && product.get().isActive() + && product.get().getType().equals(OdooConstants.PRODUCT_TYPE_STORABLE)) { Map resourceMap = Map.of( OdooConstants.MODEL_PRODUCT, product.get(),