diff --git a/distil/erp/drivers/odoo.py b/distil/erp/drivers/odoo.py index baf52e0..4f5521b 100644 --- a/distil/erp/drivers/odoo.py +++ b/distil/erp/drivers/odoo.py @@ -33,8 +33,10 @@ COMPUTE_CATEGORY = "Compute" NETWORK_CATEGORY = "Network" BLOCKSTORAGE_CATEGORY = "Block Storage" OBJECTSTORAGE_CATEGORY = "Object Storage" +DISCOUNTS_CATEGORY = "Discounts" PRODUCT_CATEGORY = [COMPUTE_CATEGORY, NETWORK_CATEGORY, - BLOCKSTORAGE_CATEGORY, OBJECTSTORAGE_CATEGORY] + BLOCKSTORAGE_CATEGORY, OBJECTSTORAGE_CATEGORY, + DISCOUNTS_CATEGORY] class OdooDriver(driver.BaseDriver): @@ -117,6 +119,15 @@ class OdooDriver(driver.BaseDriver): prices[actual_region] = collections.defaultdict(list) for product in products: + category = product['categ_id'][1].split('/')[-1].strip() + # NOTE(flwang): Always add the discount product into the + # mapping so that we can use it for /invoices API. But + # those product won't be returned as a part of the + # /products API. + self.product_category_mapping[product['id']] = category + if category == DISCOUNTS_CATEGORY: + continue + if region.upper() not in product['name_template']: continue @@ -124,10 +135,6 @@ class OdooDriver(driver.BaseDriver): if 'pre-prod' in name: continue - category = product['categ_id'][1].split('/')[-1].strip() - - self.product_category_mapping[product['id']] = category - rate = round(product['lst_price'], constants.RATE_DIGITS) # NOTE(flwang): default_code is Internal Reference on