Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
97 changes: 97 additions & 0 deletions website_sale_financial_risk/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
===========================
Website Sale Financial Risk
===========================

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

.. |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%2Fcredit--control-lightgray.png?logo=github
:target: https://github.com/OCA/credit-control/tree/18.0/website_sale_financial_risk
:alt: OCA/credit-control
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/credit-control-18-0/credit-control-18-0-website_sale_financial_risk
: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/credit-control&target_branch=18.0
:alt: Try me on Runboat

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

If a customer has sufficient credit, they can complete their purchase by
paying with a specific payment method. In this case, the order is
automatically confirmed.

**Table of contents**

.. contents::
:local:

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

Activate the ‘On credit’ payment provider and publish it on the website
so that it is available in the order payment process. Set a credit limit
and configure financial risk settings as described in the
account_financial_risk module. If the configuration has been set to
display credit information on the portal, this information will also be
displayed during the checkout process.

Usage
=====

Place an order in the online store. If you have credit available and the
order amount does not exceed the available credit, you can place the
order by selecting credit as the payment method.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/credit-control/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/credit-control/issues/new?body=module:%20website_sale_financial_risk%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>`__:

- 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/credit-control <https://github.com/OCA/credit-control/tree/18.0/website_sale_financial_risk>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions website_sale_financial_risk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions website_sale_financial_risk/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Website Sale Financial Risk",
"version": "18.0.1.0.0",
"category": "E-Commerce",
"summary": "",
"license": "AGPL-3",
"depends": ["account_financial_risk", "website_sale"],
"data": [
"templates/payment_custom_templates.xml",
"templates/website_sale_templates.xml",
"data/payment_provider_data.xml",
],
"assets": {
"web.assets_frontend": [
"website_sale_financial_risk/static/src/js/post_processing.esm.js",
],
},
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/credit-control",
"installable": True,
}
1 change: 1 addition & 0 deletions website_sale_financial_risk/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
14 changes: 14 additions & 0 deletions website_sale_financial_risk/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.http import Controller, request, route


class CreditController(Controller):
_process_url = "/payment/credit/process"

@route(_process_url, type="http", auth="public", methods=["POST"], csrf=False)
def custom_process_transaction(self, **post):
request.env["payment.transaction"].sudo()._handle_notification_data(
"credit", post
)
return request.redirect("/payment/status")
36 changes: 36 additions & 0 deletions website_sale_financial_risk/data/payment_provider_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="payment_provider_credit" model="payment.provider">
<field name="name">On Credit</field>
<field name="code">credit</field>
<field
name="image_128"
type="base64"
file="website_sale_financial_risk/static/img/icon.png"
/>
<field name="company_id" ref="base.main_company" />
<field name="redirect_form_view_id" ref="redirect_form" />
<field name="module_id" ref="base.module_website_sale_financial_risk" />
<field name="pre_msg" type="html">
<p>
<i>
The order will be confirmed <strong>on credit</strong> with no need
of instant payment, as you still have available credit.
</i>
</p>
</field>
<field name="pending_msg" type="html">
<p>
<i>Your order has been <strong>confirmed</strong>.</i><br />
The payment has been registered as <strong
>credit</strong> and is pending invoicing.
</p>
</field>
</record>

<record id="payment_method_credit" model="account.payment.method">
<field name="name">Credit</field>
<field name="code">credit</field>
<field name="payment_type">inbound</field>
</record>
</odoo>
84 changes: 84 additions & 0 deletions website_sale_financial_risk/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_financial_risk
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: it\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_financial_risk
#: model_terms:payment.provider,pre_msg:website_sale_financial_risk.payment_provider_credit
msgid ""
"<i>\n"
" The order will be confirmed <strong>on credit</strong> with no need\n"
" of instant payment, as you still have available credit.\n"
" </i>"
msgstr ""

#. module: website_sale_financial_risk
#: model_terms:payment.provider,pending_msg:website_sale_financial_risk.payment_provider_credit
msgid ""
"<i>Your order has been <strong>confirmed</strong>.</i><br>\n"
" The payment has been registered as <strong>credit</strong> and is pending invoicing."
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model.fields,field_description:website_sale_financial_risk.field_payment_provider__code
msgid "Code"
msgstr ""

#. module: website_sale_financial_risk
#: model:account.payment.method,name:website_sale_financial_risk.payment_method_credit
msgid "Credit"
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model.fields.selection,name:website_sale_financial_risk.selection__payment_provider__code__credit
#: model:payment.provider,name:website_sale_financial_risk.payment_provider_credit
msgid "On Credit"
msgstr ""

#. module: website_sale_financial_risk
#. odoo-python
#: code:addons/website_sale_financial_risk/models/payment_transaction.py:0
#, python-format
msgid "On Credit: No transaction found matching reference %s."
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model,name:website_sale_financial_risk.model_payment_provider
msgid "Payment Provider"
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model,name:website_sale_financial_risk.model_payment_transaction
msgid "Payment Transaction"
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model.fields,help:website_sale_financial_risk.field_payment_provider__code
msgid "The technical code of this payment provider."
msgstr ""

#. module: website_sale_financial_risk
#: model_terms:payment.provider,auth_msg:website_sale_financial_risk.payment_provider_credit
msgid "Your payment has been authorized."
msgstr ""

#. module: website_sale_financial_risk
#: model_terms:payment.provider,cancel_msg:website_sale_financial_risk.payment_provider_credit
msgid "Your payment has been cancelled."
msgstr ""

#. module: website_sale_financial_risk
#: model_terms:payment.provider,done_msg:website_sale_financial_risk.payment_provider_credit
msgid "Your payment has been successfully processed. Thank you!"
msgstr ""
83 changes: 83 additions & 0 deletions website_sale_financial_risk/i18n/website_sale_financial_risk.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_financial_risk
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: website_sale_financial_risk
#: model_terms:payment.provider,pre_msg:website_sale_financial_risk.payment_provider_credit
msgid ""
"<i>\n"
" The order will be confirmed <strong>on credit</strong> with no need\n"
" of instant payment, as you still have available credit.\n"
" </i>"
msgstr ""

#. module: website_sale_financial_risk
#: model_terms:payment.provider,pending_msg:website_sale_financial_risk.payment_provider_credit
msgid ""
"<i>Your order has been <strong>confirmed</strong>.</i><br>\n"
" The payment has been registered as <strong>credit</strong> and is pending invoicing."
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model.fields,field_description:website_sale_financial_risk.field_payment_provider__code
msgid "Code"
msgstr ""

#. module: website_sale_financial_risk
#: model:account.payment.method,name:website_sale_financial_risk.payment_method_credit
msgid "Credit"
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model.fields.selection,name:website_sale_financial_risk.selection__payment_provider__code__credit
#: model:payment.provider,name:website_sale_financial_risk.payment_provider_credit
msgid "On Credit"
msgstr ""

#. module: website_sale_financial_risk
#. odoo-python
#: code:addons/website_sale_financial_risk/models/payment_transaction.py:0
#, python-format
msgid "On Credit: No transaction found matching reference %s."
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model,name:website_sale_financial_risk.model_payment_provider
msgid "Payment Provider"
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model,name:website_sale_financial_risk.model_payment_transaction
msgid "Payment Transaction"
msgstr ""

#. module: website_sale_financial_risk
#: model:ir.model.fields,help:website_sale_financial_risk.field_payment_provider__code
msgid "The technical code of this payment provider."
msgstr ""

#. module: website_sale_financial_risk
#: model_terms:payment.provider,auth_msg:website_sale_financial_risk.payment_provider_credit
msgid "Your payment has been authorized."
msgstr ""

#. module: website_sale_financial_risk
#: model_terms:payment.provider,cancel_msg:website_sale_financial_risk.payment_provider_credit
msgid "Your payment has been cancelled."
msgstr ""

#. module: website_sale_financial_risk
#: model_terms:payment.provider,done_msg:website_sale_financial_risk.payment_provider_credit
msgid "Your payment has been successfully processed. Thank you!"
msgstr ""
2 changes: 2 additions & 0 deletions website_sale_financial_risk/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import payment_provider
from . import payment_transaction
40 changes: 40 additions & 0 deletions website_sale_financial_risk/models/payment_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


class PaymentProvider(models.Model):
_inherit = "payment.provider"

code = fields.Selection(
selection_add=[("credit", "On Credit")], ondelete={"credit": "set default"}
)

@api.model
def _get_compatible_providers(
self,
company_id,
*args,
sale_order_id=None,
website_id=None,
report=None,
**kwargs,
):
all_providers = super()._get_compatible_providers(
company_id,
*args,
sale_order_id=sale_order_id,
website_id=website_id,
report=report,
**kwargs,
)
# Always hide "credit" unless explicitly allowed
providers = all_providers.filtered(lambda p: p.code != "credit")
if sale_order_id:
order = self.env["sale.order"].browse(sale_order_id).exists()
if (
self.env.user.credit_limit
and self.env.user.risk_remaining_value >= order.amount_total
):
providers += all_providers.filtered(lambda p: p.code == "credit")
return providers
Loading