Metadata-Version: 2.4
Name: odoo-addon-crm_lead_token_somconnexio
Version: 16.0.1.0.0.6
Summary: Generate the crm.lead token with SomOffice, binding it to the VAT.
Home-page: https://git.coopdevs.org/coopdevs/som-connexio/odoo/odoo-somconnexio
Author: Som Connexió SCCL, Coopdevs Treball SCCL
License: AGPL-3
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 16.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Requires-Python: >=3.10
Requires-Dist: odoo-addon-cooperator_somconnexio<16.1dev,>=16.0dev
Requires-Dist: odoo-addon-crm_lead_dms_somconnexio<16.1dev,>=16.0dev
Requires-Dist: odoo-addon-crm_lead_token<16.1dev,>=16.0dev
Requires-Dist: odoo-addon-oficinavirtual_somconnexio<16.1dev,>=16.0dev
Requires-Dist: odoo<16.1dev,>=16.0a
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: home-page
Dynamic: license
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

############################
 CRM Lead Token SomConnexio
############################

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
   :alt: Beta
   :target: https://odoo-community.org/page/development-status

.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
   :alt: License: AGPL-3
   :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html

|badge1| |badge2|

This module adds the customizations of Som Connexió over the
crm_lead_token module.

The token of a crm.lead is no longer a random string generated by Odoo:
it is asked to SomOffice, the same way the invoice tokens are generated
in invoice_somconnexio. The customer VAT is implicit in the token,
because SomOffice signs the pair (user, lead):

   GET api/token/user/<vat>/lead/<lead_id>/

*****************************
 Documentation request email
*****************************

Besides the token itself, this module asks the customer to upload their
documentation. Once a ``crm.lead`` reaches the ``New`` stage
(``crm.stage_lead1``) - whether it is created directly in ``New`` or
created in another stage and later written into it - a delayed job -
``send.lead.docs.request`` - binds a SomOffice token to the lead, builds
the tokenized URL the customer uploads the documentation to
(``crm_documentation_tokenized_url``), and mails it over using the
company's ``lead_docs_request_mail_template_id``. A lead created outside
``New`` and never written into it is never asked for its documentation.

-  Nothing is asked for a lead without a VAT to bind the token to (see
   *Usage*): it keeps the random token of ``crm_lead_token``, which
   SomOffice would not resolve.

-  Nothing is sent twice: once ``crm_documentation_tokenized_url`` is
   set, a lead going through this again (e.g. created a second time by
   mistake) is left untouched, so the token's expiration keeps counting
   from the first request.

-  Passing the ``skip_documentation_stage`` context key on create
   disables the request entirely - the same context key
   ``crm_lead_dms_somconnexio`` uses to opt out of its own documentation
   review flow, so a caller opting out of one opts out of both, and does
   not need to know about SomOffice or mock it out in its own tests.

***************
 Configuration
***************

The SomOffice connection is the one already used by
oficinavirtual_somconnexio: ``SOMOFFICE_URL``, ``SOMOFFICE_USER`` and
``SOMOFFICE_PASSWORD`` environment variables.

The delay (in minutes) before the documentation request email is sent
after a lead reaches the New stage can be set in *Settings > CRM >
Documentation*, or via the
``crm_lead_token_somconnexio.send_documentation_request_minute_delay``
system parameter. It defaults to 20 minutes.

*******
 Usage
*******

Once a crm.lead reaches the New stage, its token is asked to SomOffice
using:

-  the partner VAT (``partner_id.vat``), or
-  the subscription request VAT (``subscription_request_id.vat``) when
   the lead has no partner yet.

Every lead created by our processes has a partner or a subscription
request, and the VAT is kept when a validated subscription request
creates its partner, so the token does not need to be regenerated
afterwards. Leads created without partner nor subscription request keep
the random token generated by crm_lead_token, and are not sent the
documentation request email.

*********
 Credits
*********

Authors
=======

-  Som Connexió SCCL
-  Coopdevs Treball SCCL

Contributors
============

-  `Som Connexio SCCL <https://somconnexio.coop>`_:

      -  Borja Gimeno <borja.gimeno@somconnexio.coop>
