[MERGE] forward port branch saas-11.4 up to f6ca72b3ce

This commit is contained in:
Christophe Simonis
2018-11-02 10:52:55 +01:00
73 changed files with 766 additions and 181 deletions
@@ -44,6 +44,8 @@ def tokenize(typespec):
yield (LITERAL, ast.literal_eval(string))
elif toktype == token.ENDMARKER:
return
elif toktype == token.NEWLINE:
pass
else:
raise ValueError("Unknown typespec token %s" % token.tok_name[toktype])
+1 -1
View File
@@ -220,7 +220,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
else:
opts = {}
def warner(msg):
def warner(msg, **kw):
self.builder.warn(msg, (self.builder.current_docname, node.line))
highlighted = self.builder.highlighter.highlight_block(
node.rawsource, lang, opts=opts, warn=warner, linenos=linenos,
+15
View File
@@ -0,0 +1,15 @@
The Netherlands, 2018-10-24
Brahoo B.V. agrees to the terms of the Odoo Corporate Contributor License
Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this
declaration.
Signed,
Cas Vissers c.vissers@brahoo.nl https://github.com/CasVissers
List of contributors:
Cas Vissers c.vissers@brahoo.nl https://github.com/CasVissers
+12
View File
@@ -0,0 +1,12 @@
India, 17, Sept - 2018
I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this
declaration.
Signed,
Anil Kesariya anil.r.kesariya@gmail.com https://github.com/AnilKesariya
+11
View File
@@ -0,0 +1,11 @@
Mexico, 2018-10-24
I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this
declaration.
Signed,
Luis Guzman ark@switnet.org https://github.com/ark74
+11
View File
@@ -0,0 +1,11 @@
Argentina, 2018-10-18
I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this
declaration.
Signed,
Marcelo Ariel Hamra marcelo.hamra@gmail.com https://github.com/mhamra
+3 -3
View File
@@ -1010,17 +1010,17 @@ them (e.g. to change their default sort order):
.. literalinclude:: ../../odoo/addons/test_documentation_examples/extension.py
:language: python
:lines: 5-
:lines: 7-
.. literalinclude:: ../../odoo/addons/test_documentation_examples/tests/test_extension.py
:language: python
:lines: 8,13
:lines: 10,15
will yield:
.. literalinclude:: ../../odoo/addons/test_documentation_examples/tests/test_extension.py
:language: text
:lines: 11
:lines: 13
.. note:: it will also yield the various :ref:`automatic fields
<reference/orm/model/automatic>` unless they've been disabled
+66 -22
View File
@@ -81,8 +81,11 @@ Overview
The Credits
.. note:: The credits went from integer to float value starting **October 2018**
Integer values are still supported.
Every service provided through the In-App platform can be used by the
clients with tokens or *credits*. The credits are an integer unit and
clients with tokens or *credits*. The credits are an float unit and
their monetary value depends on the service and is decided by the
provider. This could be:
@@ -157,7 +160,8 @@ The first step is to register your service on the IAP endpoint (production
and/or test) before you can actually query user accounts. To create a service,
go to your *Portal Account* on the IAP endpoint (https://iap.odoo.com for
production, https://iap-sandbox.odoo.com for testing, the endpoints are
*independent* and *not synchronized*).
*independent* and *not synchronized*). Alternatively, you can go to your portal
on Odoo (https://iap.odoo.com/my/home) and select *In-App Services*.
.. note::
@@ -166,33 +170,45 @@ production, https://iap-sandbox.odoo.com for testing, the endpoints are
on sandbox to ease the tests.
Log in then go to :menuselection:`My Account --> Your In-App Services`, click
Create and provide the name of your service.
Create and provide the informations of your service.
The now created service has *two* important fields:
The service has *four* important fields:
* :samp:`name` - :class:`ServiceName`: this will identify your service in the
client's :ref:`app <iap-odoo-app>` communicates directly with IAP.
* :samp:`key` - :class:`ServiceKey`: the developer key that identifies you in
IAP (see :ref:`your service <iap-service>`) and allows to draw credits from
the client's account.
client's :ref:`app <iap-odoo-app>` communicates directly with IAP, choose it
carefully!
.. warning::
The :class:`ServiceName` is unique and should usually match the name of your
Odoo App.
Odoo Client App.
* :samp:`Icon` - :class:`Icon`: A generic icon that will serve as default for your
:ref:`packages <iap-packages>`
* :samp:`key` - :class:`ServiceKey`: the developer key that identifies you in
IAP (see :ref:`your service <iap-service>`) and allows to draw credits from
the client's account. It will be shown only once upon creation of the service
and can be regenerated at will.
.. danger::
Your :class:`ServiceKey` *is a secret*, leaking your service key
allows other application developers to draw credits bought for
your service(s).
.. image:: images/service_select.png
* :samp:`privacy policy` - :class:`PrivacyPolicy`: This is an url to the privacy
policy of your service. This should explicitly mention the **information you collect**,
How you **use it, its relevance** to make your service work and inform the
client on how they can **access, update or delete their personal information**.
.. image:: images/menu.png
:align: center
.. image:: images/service_create.png
.. image:: images/service_list.png
:align: center
.. image:: images/service_packs.png
.. image:: images/creating_service.png
:align: center
.. image:: images/service_created.png
:align: center
You can then create *credit packs* which clients can purchase in order to
@@ -203,9 +219,10 @@ use your service.
Packages
--------
The credit packages are essentially a product with 4 characteristics.
The credit packages are essentially a product with 5 characteristics.
* Name: the name of the package,
* Icon: A specific icon for the package. If not provided, it will fallback on the service icon
* Description: details on the package that will appear on the shop page as
well as the invoice,
* Credits: the amount of credits the client is entitled to when buying the package,
@@ -362,7 +379,6 @@ parameters we can use to make things clearer to the end-user:
.. patch::
.. TODO:: how do you test your service?
JSON-RPC2_ Transaction API
@@ -394,13 +410,13 @@ Authorize
:param ServiceKey key:
:param UserToken account_token:
:param int credit:
:param float credit:
:param str description: optional, helps users identify the reason for
charges on their accounts.
:returns: :class:`TransactionToken` if the authorization succeeded.
:raises: :class:`~odoo.exceptions.AccessError` if the service token is invalid
:raises: :class:`~odoo.addons.iap.models.iap.InsufficientCreditError` if the account does
:raises: ``TypeError`` if the ``credit`` value is not an integer
:raises: ``TypeError`` if the ``credit`` value is not an integer or a float
.. code-block:: python
@@ -434,7 +450,7 @@ Capture
:param TransactionToken token:
:param ServiceKey key:
:param int credit_to_capture: (new - 15 Jan 2018) optional parameter to capture a smaller amount of credits than authorized
:param float credit_to_capture: (new - 15 Jan 2018) optional parameter to capture a smaller amount of credits than authorized
:raises: :class:`~odoo.exceptions.AccessError`
.. code-block:: python
@@ -534,6 +550,33 @@ care how they are implemented
Raised by any unexpeted behaviour at the discretion of the App developer (*you*).
Test the API
------------
In order to test the developped app, we propose a sandbox platform that allows you to:
1. Test the whole flow from the client's point of view - Actual services and transactions
that can be consulted. (again this requires to change the endpoint, see the danger note
in :ref:`Service <iap-service>`)
2. Test the API.
The latter consists in specific tokens that will work on **IAP-Sandbox only**.
* token ``000000``: represents a non-existing account. Returns
an :class:`~odoo.addons.iap.models.iap.InsufficientCreditError` on authorize attempt.
* token ``000111``: Represents an account without sufficient credits to perform any service.
Returns an :class:`~odoo.addons.iap.models.iap.InsufficientCreditError` on authorize attempt.
* token ``111111``: Represents an account with enough credits to perform any service.
An authorize attempt will return a dummy transacion token that is processed by the capture
and cancel routes.
.. note::
* Those tokens are only active on the IAP-Sanbox server.
* The service key is completely ignored with this flow, If you want to run a robust test
of your service, you should ignore these tokens.
Odoo Helpers
============
@@ -548,7 +591,7 @@ Charging
.. note::
A new functionality was introduced to capture a different amount of credits than reserved.
As this patch was added on the 15th of January 2018, you will need to upgrade your ``iap`` module in order to use it.
As this patch was added on the **15th of January 2018**, you will need to upgrade your ``iap`` module in order to use it.
The specifics of the new functionality are highlighted in the code.
.. class:: odoo.addons.iap.models.iap.charge(env, key, account_token, credit[, description, credit_template])
@@ -567,12 +610,12 @@ Charging
configuration key
:param ServiceKey key:
:param UserToken token:
:param int credit:
:param float credit:
:param str description:
:param Qweb template credit_template:
.. code-block:: python
:emphasize-lines: 10,13,14,15
:emphasize-lines: 11,13,14,15
@route('/deathstar/superlaser', type='json')
def superlaser(self, user_account,
@@ -583,7 +626,8 @@ Charging
0.0 is none, 1.0 is full power
"""
credits = int(MAXIMUM_POWER * factor)
with charge(request.env, SERVICE_KEY, user_account, credits) as transaction:
description = "We will demonstrate the power of this station on your home planet of Alderaan."
with charge(request.env, SERVICE_KEY, user_account, credits, description) as transaction:
# TODO: allow other targets
transaction.credit = max(credits, 2)
# Sales ongoing one the energy price,
Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB