Support discount for prodcut category mapping
To show the discount info in invoice, it's necessary to add discount into the discount/category mapping. Change-Id: I53580eaafbd80bd9efd9a17eab03d42bf1edf481
This commit is contained in:
parent
e61b323a32
commit
6d990b6ca6
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue