From 7e47ebe512710db4ac581ff2799edb5e125fbbc1 Mon Sep 17 00:00:00 2001 From: Feilong Wang Date: Wed, 2 Aug 2017 05:20:05 +1200 Subject: [PATCH] Improve cache about get products For most of the cases of Distil API, the request comes from billing panel. Billing panel sends 1 API call for /invoices and several API calls for /quotations against different regions. So it's not efficient to specify the region for get_products method because it won't help cache the products based on the parameters. Change-Id: I2f7e2ce8c3f43e79b9e9084903fca1bc4f44f82a --- distil/erp/drivers/odoo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/distil/erp/drivers/odoo.py b/distil/erp/drivers/odoo.py index a5ee380..d4d32e9 100644 --- a/distil/erp/drivers/odoo.py +++ b/distil/erp/drivers/odoo.py @@ -385,7 +385,12 @@ class OdooDriver(driver.BaseDriver): odoo_region = self.region_mapping.get(region, region).upper() resources = {row.id: json.loads(row.info) for row in resources} - products = self.get_products([region])[region] + # NOTE(flwang): For most of the cases of Distil API, the request comes + # from billing panel. Billing panel sends 1 API call for /invoices and + # several API calls for /quotations against different regions. So it's + # not efficient to specify the region for get_products method because + # it won't help cache the products based on the parameters. + products = self.get_products()[region] service_mapping = self._get_service_mapping(products) for entry in measurements: