Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.0] [ADD] contract_auto: Automatic Payment For Contracts #67

Merged
merged 1 commit into from
Oct 16, 2017
Merged
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
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ python:

addons:
apt:
# only add the two lines below if you need wkhtmltopdf for your tests
# sources:
# - pov-wkhtmltopdf
sources:
- pov-wkhtmltopdf
packages:
- expect-dev # provides unbuffer utility
- python-lxml # because pip installation is slow
- python-simplejson
- python-serial
- python-yaml
# - wkhtmltopdf # only add if needed and check the before_install section below
- wkhtmltopdf

# set up an X server to run wkhtmltopdf.
#before_install:
# - "export DISPLAY=:910.0"
# - "sh -e /etc/init.d/xvfb start"
before_install:
- "export DISPLAY=:910.0"
- "sh -e /etc/init.d/xvfb start"

env:
global:
- VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
- TRANSIFEX_USER='transbot@odoo-community.org'
- WKHTMLTOPDF_VERSION="0.12.4"
- secure: ArnbVaF5+ry6zVysZ7HA9xcnQrodo8FsXXcon9yINTYRfDC9QEr+/mTLAPRl+lVLdtWV2GuGuX0vPYzBxFWpY3LR0BpKqXzx0G51s94zR2WWEmizYFzFhpAuIxoU4CYNckHFSUaPAQJhwB/pYx9+H/W6bMjG/VnZBq+AmBJ2Kh0=

matrix:
Expand Down
89 changes: 89 additions & 0 deletions contract_payment_auto/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. 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>


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.
5 changes: 5 additions & 0 deletions contract_payment_auto/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
27 changes: 27 additions & 0 deletions contract_payment_auto/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# 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": "10.0.1.0.0",
"category": "Contract Management",
"license": "AGPL-3",
"author": "LasLabs, "
"Odoo Community Association (OCA)",
"website": "https://laslabs.com",
"depends": [
"contract",
"payment",
],
"data": [
"data/mail_template_data.xml",
"data/ir_cron_data.xml",
"views/account_analytic_account_view.xml",
"views/account_analytic_contract_view.xml",
"views/res_partner_view.xml",
],
"installable": True,
"application": False,
}
19 changes: 19 additions & 0 deletions contract_payment_auto/data/ir_cron_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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="interval_type">hours</field>
<field name="interval_number">1</field>
<field name="model">account.analytic.account</field>
<field name="function">cron_retry_auto_pay</field>
<field name="args">()</field>
</record>

</odoo>
98 changes: 98 additions & 0 deletions contract_payment_auto/data/mail_template_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?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 '')|safe}</field>
<field name="subject">Automatic Payment Failure (Ref ${object.number or 'n/a'})</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="auto_delete" eval="True"/>
<field name="report_template" ref="account.account_invoices"/>
<field name="report_name">Invoice_${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html"><![CDATA[

<p>
Hello ${object.partner_id.name}
% set access_action = object.get_access_action()
% set access_url = access_action['type'] == 'ir.actions.act_url' and access_action['url'] or '/report/pdf/account.report_invoice/' + str(object.id)
% if object.partner_id.parent_id:
(<i>${object.partner_id.parent_id.name}</i>)
% endif
,
</p>

<p>
The automatic payment for your invoice
<a href="${access_url}">
<strong>
${object.number}
</strong>
% if object.origin:
(with reference: ${object.origin} )
% endif
</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 '')|safe}</field>
<field name="subject">Automatic Payment Failure (Ref ${object.number or 'n/a'})</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="auto_delete" eval="True"/>
<field name="report_template" ref="account.account_invoices"/>
<field name="report_name">Invoice_${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html"><![CDATA[

<p>
Hello ${object.partner_id.name}
% set access_action = object.get_access_action()
% set access_url = access_action['type'] == 'ir.actions.act_url' and access_action['url'] or '/report/pdf/account.report_invoice/' + str(object.id)
% if object.partner_id.parent_id:
(<i>${object.partner_id.parent_id.name}</i>)
% endif
,
</p>

<p>
The automatic payment for your invoice
<a href="${access_url}">
<strong>
${object.number}
</strong>
% if object.origin:
(with reference: ${object.origin} )
% endif
</a>
failed.
</p>

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

]]>
</field>
</record>

</odoo>
8 changes: 8 additions & 0 deletions contract_payment_auto/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import account_analytic_account
from . import account_analytic_contract
from . import account_invoice
from . import res_partner
Loading