From a0b7802a5e7646a896f54cf125f0136ff489d4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir?= Date: Fri, 21 Sep 2018 11:10:00 +0200 Subject: [PATCH] [WIP] iap: adapt the charge to trail system. We added the possibility to provide the dbuuid of the client when trying to authorize a transaction. This will allow to automatically credit the client accounts that can beneficiate from free trial credits. This improvement will ease the life of the client as they will not have to go to iap.odoo.com to charge their account. --- addons/iap/models/iap.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/iap/models/iap.py b/addons/iap/models/iap.py index 64830bfa24e..0c116ce6bc6 100644 --- a/addons/iap/models/iap.py +++ b/addons/iap/models/iap.py @@ -78,7 +78,7 @@ class IapTransaction(object): self.credit = None @contextlib.contextmanager -def charge(env, key, account_token, credit, description=None, credit_template=None): +def charge(env, key, account_token, credit, dbuuid=False, description=None, credit_template=None): """ Account charge context manager: takes a hold for ``credit`` amount before executing the body, then captures it if there @@ -103,6 +103,8 @@ def charge(env, key, account_token, credit, description=None, credit_template=No 'key': key, 'description': description, } + if dbuuid: + params.update({'dbuuid': dbuuid}) try: transaction_token = jsonrpc(endpoint + '/iap/1/authorize', params=params) except InsufficientCreditError as e: