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
This commit is contained in:
Feilong Wang 2017-08-02 05:20:05 +12:00
parent d906c733a2
commit 7e47ebe512
1 changed files with 6 additions and 1 deletions

View File

@ -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: