Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c197faf
[ADD] contract_auto: Automatic Payment For Contracts
lasley May 5, 2017
aea7bd5
OCA Transbot updated translations from Transifex
oca-transbot Dec 2, 2017
916bcdc
[FIX] contract_payment_auto: Switch test to HttpCase
pedrobaeza Nov 7, 2017
decf93b
[FIX] contract_payment_auto: Fix RST syntax
pedrobaeza Nov 7, 2017
f97554b
[FIX] contract_payment_auto: Fix freze wkhtmltopdf freezed
moylop260 Nov 10, 2017
ac7914a
OCA Transbot updated translations from Transifex
oca-transbot Dec 9, 2017
ce37e1a
[FIX] contract_payment_auto: transaction create must always get a tok…
fcayre May 28, 2018
c9c07e4
OCA Transbot updated translations from Transifex
oca-transbot Jun 2, 2018
d3c5d74
[UPD] Update contract_payment_auto.pot
oca-travis Jul 21, 2018
82020fe
[ADD] icon.png
OCA-git-bot Apr 3, 2019
64a4df8
Translated using Weblate (German)
marylla Feb 22, 2019
a45e806
[MIG] contract_payment_auto: Migration to 12.0
norlinhenrik Dec 19, 2019
3d66a57
[MIG][FIX] contract_payment_auto: Migration to 12.0
norlinhenrik Dec 21, 2019
60c65a2
[MIG][FIX2] contract_payment_auto: Migration to 12.0
norlinhenrik Jul 17, 2020
b62f9bd
[MIG][FIX3] contract_payment_auto: Migration to 12.0
norlinhenrik Jul 22, 2020
e105365
[FIX] Make payment work with several invoices and contracts to be paid
fcayre Aug 31, 2020
f827248
[IMP] Fix small docstring typo
fcayre Aug 31, 2020
8a26277
Fix tests
fcayre Mar 3, 2022
607ce2f
Reactivate all tests and fix them
fcayre Mar 3, 2022
dd9a5fc
Do not crash if generated invoice has no line
fcayre Mar 3, 2022
923da14
[FIX] Add invoice on created payment transactions
fcayre Jul 2, 2022
647df71
[IMP] contract_payment_auto: black, isort, prettier
Apr 15, 2025
1f29644
[MIG] contract_payment_auto: Migration to 16.0
Apr 15, 2025
9b520fb
[IMP] contract_payment_auto: Replace model mock by model injection
Apr 17, 2025
27fa8fa
[IMP] contract_payment_auto: Improve test readability
Apr 23, 2025
cd17399
[IMP] contract_payment_auto: Move setUp to setUpClass to improve effi…
Apr 23, 2025
60087a5
[IMP] contract_payment_auto: Make test class depend on TestContractBase
Apr 23, 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
96 changes: 96 additions & 0 deletions contract_payment_auto/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=====================
Contract Auto Payment
=====================

This module allows for the configuration of automatic payments on invoices that are created by a contract.

Usage
=====

Enable Automatic Payment
------------------------

* Navigate to a customer contract
* Check the `Auto Pay?` box to enable automatic payment
* Configure the options as desired
* Set the `Payment Token` to the payment token that should be used for automatic payment

Automatic Payment Settings
--------------------------

The following settings are available at both the contract and contract template level:

+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
| Name | Description |
+=======================+===============================================================================================================================================+
| Invoice Message | Message template that is used to send invoices to customers upon creation. |
+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
| Payment Retry Message | Message template that is used to alert a customer that their automatic payment failed for some reason and will be retried. |
+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
| Payment Fail Message | Message template that is used to alert a customer that their automatic payment failed and will no longer be retried. |
+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
| Auto Pay Retries | Amount of times to attempt an automatic payment before discontinuing and removing the payment token from the contract/account payment method. |
+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
| Auto Pay Retry Hours | Amount of hours that should lapse until retrying failed payments. |
+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+

Payment Token
-------------

A valid payment token is required to use this module. These tokens are typically created during the `website_sale` checkout process, but they can also be created manually at the acquirer.

A payment token can be defined in one of two areas:

* Contract - Defining a payment token in the contract will allow for the use of this token for automatic payments on this contract only.
* Partner - Defining a payment token in the partner will allow for the use of this token for automatic payments on all contracts for this partner that do not have a payment token defined.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/110/10.0

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

* None

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

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/contract/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

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

* Dave Lasley <dave@laslabs.com>
* Henrik Norlin <henrik@appstogrow.co>


Maintainer
----------

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

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
4 changes: 4 additions & 0 deletions contract_payment_auto/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
25 changes: 25 additions & 0 deletions contract_payment_auto/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Contract - Auto Payment",
"summary": "Adds automatic payments to contracts.",
"version": "16.0.1.0.0",
"category": "Contract Management",
"license": "AGPL-3",
"author": "LasLabs, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/contract",
"depends": [
"contract",
"payment",
],
"data": [
"data/mail_template_data.xml",
"data/ir_cron_data.xml",
"views/contract_view.xml",
"views/contract_template_view.xml",
"views/res_partner_view.xml",
],
"installable": True,
"application": False,
}
18 changes: 18 additions & 0 deletions contract_payment_auto/data/ir_cron_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2017 LasLabs Inc.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo noupdate="1">

<record id="ir_cron_auto_pay" model="ir.cron">
<field name="name">Contract Automatic Payments</field>
<field name="model_id" ref="model_contract_contract" />
<field name="state">code</field>
<field name="code">model.cron_retry_auto_pay()</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_type">hours</field>
<field name="interval_number">1</field>
</record>

</odoo>
112 changes: 112 additions & 0 deletions contract_payment_auto/data/mail_template_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2017 LasLabs Inc.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo noupdate="1">

<record id="mail_template_auto_pay_retry" model="mail.template">
<field name="name">Invoice - AutoPay To Retry</field>
<field
name="email_from"
>{{(object.user_id.email and '%s &lt;%s&gt;' % (object.user_id.name, object.user_id.email) or '')}}</field>
<field
name="subject"
>Automatic Payment Failure (Ref {{object.name or 'n/a'}})</field>
<field name="partner_to">{{object.partner_id.id}}</field>
<field name="model_id" ref="account.model_account_move" />
<field name="auto_delete" eval="True" />
<field name="report_template" ref="account.account_invoices" />
<field
name="report_name"
>Invoice_{{(object.name or '').replace('/','_')}}_{{object.state == 'draft' and 'draft' or ''}}</field>
<field name="lang">{{object.partner_id.lang}}</field>
<field
name="body_html"
><![CDATA[

<p>
Hello <t t-out="object.partner_id.name" />
<t t-set="access_action" t-value="object.get_formview_action()"/>
<t t-set="access_url" t-value="access_action['type'] == 'ir.actions.act_url' and access_action['url'] or '/report/pdf/account.report_invoice/' + str(object.id)"/>
<t t-if="object.partner_id.parent_id">
(<i><t t-out="object.partner_id.parent_id.name" /></i>)
</t>
,
</p>

<p>
The automatic payment for your invoice
<a t-attf-href="{{access_url}}">
<strong>
<t t-out="object.name" />
</strong>
<t t-if="object.invoice_origin">
(with reference: <t t-out="object.invoice_origin" /> )
</t>
</a>
failed.
</p>

<p>
Please verify that your payment information is correct, and that funds are
available in the account.
</p>

]]>
</field>
</record>

<record id="mail_template_auto_pay_fail" model="mail.template">
<field name="name">Invoice - AutoPay Failed</field>
<field
name="email_from"
>{{(object.user_id.email and '%s &lt;%s&gt;' % (object.user_id.name, object.user_id.email) or '')}}</field>
<field
name="subject"
>Automatic Payment Failure (Ref {{object.name or 'n/a'}})</field>
<field name="partner_to">{{object.partner_id.id}}</field>
<field name="model_id" ref="account.model_account_move" />
<field name="auto_delete" eval="True" />
<field name="report_template" ref="account.account_invoices" />
<field
name="report_name"
>Invoice_{{(object.name or '').replace('/','_')}}_{{object.state == 'draft' and 'draft' or ''}}</field>
<field name="lang">{{object.partner_id.lang}}</field>
<field
name="body_html"
><![CDATA[

<p>
Hello <t t-out="object.partner_id.name" />
<t t-set="access_action" t-value="object.get_formview_action()"/>
<t t-set="access_url" t-value="access_action['type'] == 'ir.actions.act_url' and access_action['url'] or '/report/pdf/account.report_invoice/' + str(object.id)"/>
<t t-if="object.partner_id.parent_id">
(<i><t t-out="object.partner_id.parent_id.name" /></i>)
</t>
,
</p>

<p>
The automatic payment for your invoice
<a t-attf-href="{{access_url}}">
<strong>
<t t-out="object.name" />
</strong>
<t t-if="object.invoice_origin">
(with reference: <t t-out="object.invoice_origin" /> )
</t>
</a>
failed.
</p>

<p>
Please verify that your payment information is correct, and that funds are
available in the account.
</p>

]]>
</field>
</record>

</odoo>
Loading