Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5f464f6
[ADD] website_sale_require_legal
yajo Oct 26, 2015
587d2c0
[9.0] [MIG] website_sale_require_legal module
cubells Dec 23, 2016
c03bc7e
[MIG][website_sale_require_legal] Migrate to v10
yajo Sep 6, 2017
ea470b4
website_sale_require_legal: Fix rendering error when error list is empty
grindtildeath May 3, 2018
58bda43
[IMP] record metadata on registration and acceptance of conditions
chienandalu May 25, 2018
fad7808
[MIG] website_sale_require_legal: Migration to 11.0
ernestotejeda Jun 12, 2018
94eb9e0
[12.0][MIG] website_sale_require_legal: Migration to v12
Feb 26, 2019
ed437ab
[FIX] website_sale_require_legal: Turn tour green
yajo Apr 16, 2019
0d7fb71
[FIX] website_sale_require_legal: Tour Test
Tardo May 17, 2019
d890638
Added translation using Weblate (Finnish)
Mar 16, 2020
9a746e5
[MIG] website_sale_require_legal: Migration to 13.0
Oct 7, 2020
d91db7c
[IMP] website_sale_require_legal: document, fix and test new module s…
Jul 12, 2021
c7dc18a
Translated using Weblate (Spanish)
macagua May 24, 2022
65a7bb9
[MIG] website_sale_require_legal: Migration to 14.0
willytal Jul 8, 2022
9ef9366
[MIG] website_sale_require_legal: Migration to version 15.0
pilarvargas-tecnativa Jan 23, 2023
3a70dd4
[FIX] website_sale_require_legal: tests
chienandalu Jan 25, 2023
f27921d
[FIX] website_sale_require_legal: remove dependency to website_legal_…
pilarvargas-tecnativa Feb 23, 2023
e0158ac
Translated using Weblate (Spanish)
Ivorra78 Jul 5, 2023
d3281ec
[MIG] website_sale_require_legal: Migration to version 16.0
pilarvargas-tecnativa Oct 3, 2023
934dbcf
[FIX] website_sale_require_legal: Test compatibility with website_sal…
pilarvargas-tecnativa Nov 7, 2023
32e952a
Translated using Weblate (Italian)
mymage May 7, 2024
a95a85b
[IMP] website_sale_require_legal: pre-commit auto fixes
pilarvargas-tecnativa Nov 15, 2024
a7e20c8
[MIG] website_sale_require_legal: Migration to version 17.0
pilarvargas-tecnativa Nov 18, 2024
cc3193c
[IMP] website_sale_require_legal: pre-commit auto fixes
eduezerouali-tecnativa Sep 5, 2025
06759f9
[MIG] website_sale_require_legal: Migration to 18.0
eduezerouali-tecnativa Sep 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions website_sale_require_legal/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
=========================================
Require accepting legal terms to checkout
=========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:110fc2437cf0a83c09c41f0e87bf5281edfcc18d1471243bd25fc01b38162e13
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/18.0/website_sale_require_legal
:alt: OCA/e-commerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_require_legal
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends your e-commerce legal compliance options:

1. Require accepting legal terms before submitting a new address.
2. Log a note in the partner when such terms are accepted.
3. Log a note in the sale order when terms are accepted before payment
(done for every online payment, it is an upstream feature).

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

This module adds the functionality to require the user to check the
checkbox to accept the legal terms in the address form. Additionally, it
provides a metadata record for both the user when legal terms are
accepted through the address form and for the sales order when legal
terms are accepted during the payment process.

It's worth noting that this module can be useful even if the acceptance
of legal terms in the address form is not activated, as it stores a
metadata record when the terms and conditions are accepted during the
payment process, even if a new address has not been created.

Configuration
=============

To configure this module, you need to:

1. Install it.

2. Set up `your legal pages </legal>`__.

3. Go to your e-commerce and make a sample checkout.

4. Visit `/shop/address </shop/address>`__ and enable in the web editor
*Customize > Require Legal Terms Acceptance*.

|image1|

This will require acceptance before recording a new address, and log
visitor's acceptance.

5. Visit `/shop/payment </shop/payment>`__ and enable in the web editor
*Customize > Accept Terms & Conditions* (upstream Odoo feature).

|image2|

This will require acceptance before paying the sale order, and log
visitor's acceptance.

.. |image1| image:: https://raw.githubusercontent.com/OCA/e-commerce/18.0/website_sale_require_legal/static/description/address-enable.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/e-commerce/18.0/website_sale_require_legal/static/description/payment-enable.png

Usage
=====

To use this module, you need to:

- Buy something from your website.

Known issues / Roadmap
======================

- Shopping terms and conditions are accepted only on user registration
or address edition. So if those terms change after the user signed up,
a notification should be made. An implicit acceptance could be printed
in the payment screen to solve this. Maybe that could be a work to
develop in another module.
- If you enable both acceptance views as explained in the configuration
section, first-time buyers will have to accept the legal terms between
2 and 3 times to buy.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_require_legal%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Rafael Blasco
- Jairo Llopis
- Vicent Cubells
- David Vidal
- Ernesto Tejeda
- Cristina Martin R.
- Pilar Vargas

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/18.0/website_sale_require_legal>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions website_sale_require_legal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import controllers
25 changes: 25 additions & 0 deletions website_sale_require_legal/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2015, 2017, 2021 Tecnativa - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# Copyright 2019 Tecnativa - Cristina Martin R.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Require accepting legal terms to checkout",
"summary": "Force the user to accept legal tems to buy in the web shop",
"version": "18.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["website_sale"],
"data": ["templates/website_sale.xml"],
"assets": {
"web.assets_frontend": [
"/website_sale_require_legal/static/src/scss/website_sale_require_legal.scss",
],
"web.assets_tests": [
"/website_sale_require_legal/static/tests/tours/tour.esm.js",
],
},
}
2 changes: 2 additions & 0 deletions website_sale_require_legal/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import main
120 changes: 120 additions & 0 deletions website_sale_require_legal/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Copyright 2015-2017 Tecnativa - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from markupsafe import Markup

from odoo import http
from odoo.http import request, route

from odoo.addons.payment.controllers import portal
from odoo.addons.website_sale.controllers import main


class WebsiteSale(main.WebsiteSale):
def _validate_address_values(
self,
address_values,
partner_sudo,
address_type,
use_delivery_as_billing,
required_fields,
is_main_address,
**_kwargs,
):
invalid_fields, missing_fields, error_messages = (
super()._validate_address_values(
address_values,
partner_sudo,
address_type,
use_delivery_as_billing,
required_fields,
is_main_address,
**_kwargs,
)
)
if not _kwargs.get("accepted_legal_terms"):
error_messages.append(
request.env._("You must accept the terms & conditions to continue.")
)

return invalid_fields, missing_fields, error_messages

@route(
"/shop/address/submit",
type="http",
methods=["POST"],
auth="public",
website=True,
sitemap=False,
)
def shop_address_submit(
self,
partner_id=None,
address_type="billing",
use_delivery_as_billing=None,
callback=None,
required_fields=None,
**form_data,
):
res = super().shop_address_submit(
partner_id=partner_id,
address_type=address_type,
use_delivery_as_billing=use_delivery_as_billing,
callback=callback,
required_fields=required_fields,
**form_data,
)
if partner_id:
partner = request.env["res.partner"].browse(int(partner_id))
if form_data.get("accepted_legal_terms"):
self._log_acceptance_metadata(partner)
return res

def _log_acceptance_metadata(self, record):
"""Log legal terms acceptance metadata."""
environ = request.httprequest.headers.environ
metadata = "<br/>".join(
f"{val}: {environ.get(val)}"
for val in (
"REMOTE_ADDR",
"HTTP_USER_AGENT",
"HTTP_ACCEPT_LANGUAGE",
)
)
message = Markup(
request.env._("Website legal terms acceptance metadata: %s") % metadata
)
record.sudo().message_post(
body=message, message_type="notification", subtype_xmlid="mail.mt_comment"
)


class PaymentPortal(portal.PaymentPortal):
@http.route()
def shop_payment_transaction(self, order_id, access_token, **kwargs):
"""Record sale order payment legal terms acceptance.

If the "Accept Terms & Conditions" upstream view is enabled in the
website, to get here, user must have accepted legal terms.
"""
result = super().shop_payment_transaction(order_id, access_token, **kwargs)
# If the "Accept Terms & Conditions" view is disabled, we log nothing
if not request.website.viewref(
"website_sale.accept_terms_and_conditions"
).active:
return result
# Retrieve the sale order
if order_id:
sale_obj = request.env["sale.order"]
domain = [("id", "=", order_id)]
if access_token:
sale_obj = sale_obj.sudo()
domain.append(("access_token", "=", access_token))
order = sale_obj.search(domain, limit=1)
else:
order = request.website.sale_get_order()
# Log metadata in the sale order
if order:
WebsiteSale._log_acceptance_metadata(self, order)
return result
43 changes: 43 additions & 0 deletions website_sale_require_legal/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_require_legal
#
# Translators:
# Rudolf Schnapka <rs@techno-flex.de>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-20 01:42+0000\n"
"PO-Revision-Date: 2017-05-20 01:42+0000\n"
"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>, 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: website_sale_require_legal
#: model_terms:ir.ui.view,arch_db:website_sale_require_legal.accept_input
msgid "I agree to the"
msgstr ""

#. module: website_sale_require_legal
#. odoo-python
#: code:addons/website_sale_require_legal/controllers/main.py:0
#, python-format
msgid "Website legal terms acceptance metadata: %s"
msgstr ""

#. module: website_sale_require_legal
#: model_terms:ir.ui.view,arch_db:website_sale_require_legal.accept_input
msgid "terms &amp; conditions"
msgstr ""

#~ msgid ""
#~ "Confirm\n"
#~ " <span class=\"fa fa-long-arrow-right\"/>"
#~ msgstr ""
#~ "Bestätigen\n"
#~ " <span class=\"fa fa-long-arrow-right\"/>"
37 changes: 37 additions & 0 deletions website_sale_require_legal/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_require_legal
#
# Translators:
# Pedro M. Baeza <pedro.baeza@gmail.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-07 02:00+0000\n"
"PO-Revision-Date: 2023-07-05 14:08+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: website_sale_require_legal
#: model_terms:ir.ui.view,arch_db:website_sale_require_legal.accept_input
msgid "I agree to the"
msgstr "Estoy de acuerdo con el/la"

#. module: website_sale_require_legal
#. odoo-python
#: code:addons/website_sale_require_legal/controllers/main.py:0
#, python-format
msgid "Website legal terms acceptance metadata: %s"
msgstr "Metadatos de aceptación de los términos legales del sitio web: %s"

#. module: website_sale_require_legal
#: model_terms:ir.ui.view,arch_db:website_sale_require_legal.accept_input
msgid "terms &amp; conditions"
msgstr "términos y plazos; condiciones"
Loading