Compare commits

...

2 Commits

Author SHA1 Message Date
wilsongomez 4a7c74abb6 minor fix 2022-06-21 10:31:27 -05:00
wilsongomez 8aac4f504a minor fix function require_appkey 2022-06-21 08:32:08 -05:00
2 changed files with 8 additions and 3 deletions

View File

@ -24,6 +24,8 @@ config.read(config_file)
trytond_config = get_config('trytond_config')
host_ = config.get('General', 'host')
API_KEY = config.get('Auth', 'api_key')
API_KEY_VO = config.get('Auth', 'api_key_vo')
context = {'company': 1, 'user': 1}
# The actual decorator function
@ -31,7 +33,10 @@ def require_appkey(view_function):
@wraps(view_function)
# the new, post-decoration function. Note *args and **kwargs here.
def decorated_function(*args, **kwargs):
if request.headers.get('Authorization') and request.headers.get('Authorization') == API_KEY:
auth = request.headers.get('Authorization')
print( 'esta llego mano ... ', auth)
print( 'esta clave ... ', API_KEY, ' : ', API_KEY_VO)
if auth and auth in [API_KEY, API_KEY_VO]:
return view_function(*args, **kwargs)
else:
abort(401)
@ -266,13 +271,13 @@ def create_app(dbname):
prices2product = {p['template']: p['list_price'] for p in prices}
for val in values:
template = val.template
if val.components_used:
list_price = sum(k.product.list_price * Decimal(k.quantity) for k in val.components_used)
sale_price_w_tax = sum(k.product.template.sale_price_w_tax * Decimal(k.quantity) for k in val.components_used)
else:
list_price = float(round(prices2product[template.id], 2))
sale_price_w_tax = float(round(template.sale_price_w_tax, 2))
template = val.template
product = {
'id': val.id,
'name': template.name,

View File

@ -271,11 +271,11 @@ def create_app(dbname):
prices2product = {p['template']: p['list_price'] for p in prices}
for val in values:
template = val.template
if val.components_used:
list_price = sum(k.product.list_price * Decimal(k.quantity) for k in val.components_used)
else:
list_price = float(round(prices2product[template.id], 2))
template = val.template
product = {
'id': val.id,
'name': template.name,