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

[16.0] Donation new features: Generate a Certificate, Thanks Letter, Summary and recurrency #125

Closed
wants to merge 26 commits into from
Closed
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
8 changes: 8 additions & 0 deletions donation/tests/test_donation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ class TestDonation(TransactionCase):

def setUp(self):
super().setUp()
donation_debit_order_account = self.env["account.account"].create(
{
"code": "1013Don",
"name": "Account Receivable Don",
"account_type": "asset_receivable",
}
)
self.bank_journal = self.env["account.journal"].create(
{
"type": "bank",
"name": "test bank journal",
"donation_debit_order_account_id": donation_debit_order_account.id,
}
)
self.payment_mode = self.env["account.payment.mode"].create(
Expand Down
108 changes: 108 additions & 0 deletions donation_certificate/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
=====================
Donation Certificate
=====================

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

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

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

The Donation Certificate module provides users with the capability to customize certificates to be sent to donors.
These certificates are linked to fields within the "donation.donation"
model and are formatted as ODT files for easy editing.
Additionally, this module enables users to send certificates in bulk and print them.

**Table of contents**

.. contents::
:local:

Features
=============

* **Customization**: Users can personalize certificates to be sent to donors, tailoring them to specific donation details.
* **Integration**: The module seamlessly integrates with the "donation.donation" model, ensuring accurate and relevant information on the certificates.
* **ODT Format**: Certificates are generated in the ODT format, facilitating easy editing using standard office software.
* **Mass Sending**: Users have the option to send certificates to multiple donors simultaneously, streamlining the process for efficiency.
* **Printing**: The module supports printing functionality, allowing users to produce physical copies of certificates as needed.

Usage
=====

Once installed, users can access the Donation Certificate functionality through the Odoo interface. Here's a brief overview of how to use the module:

1. Navigate to the Donation Certificate section in the Odoo interface.
2. Customize the certificate template as desired, ensuring it reflects the necessary donation information.
3. Select the donors to whom the certificates should be sent.
4. Send the certificates individually or in bulk.
5. Optionally, print physical copies of the certificates for distribution.


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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/donation/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/donation/issues/new?body=module:%20donation_certificate%0Aversion:%2016.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
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Alexis de Lattre <alexis.delattre@akretion.com>

Maintainers
~~~~~~~~~~~

This module is maintained by brendajfa.

.. 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.

.. |maintainer-brendajfa| image:: https://github.com/alexis-via.png?size=40px
:target: https://github.com/alexis-via
:alt: alexis-via

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-brendajfa|

This module is part of the `OCA/donation <https://github.com/OCA/donation/tree/16.0/donation_direct_debit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions donation_certificate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
from . import wizard
28 changes: 28 additions & 0 deletions donation_certificate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Donation Certificate",
"summary": "Donation Certificate",
"version": "16.0.1.0.0",
"category": "Custom",
"website": "https://github.com/OCA/donation",
"author": "Barroux Abbey, Akretion, Odoo Community Association (OCA)",
"maintainers": ["brendajfa"],
"license": "AGPL-3",
"application": True,
"installable": True,
"depends": ["report_py3o", "donation", "donation_base", "mail"],
"data": [
"security/ir.model.access.csv",
"data/mail_template.xml",
"data/donation_sequence.xml",
"data/py3o_certificate_template.xml",
"views/donation_certificate_send_views.xml",
"views/tax_receipt_donation.xml",
"views/donation_send_cert_button.xml",
"views/py3o_certificate_report.xml",
"wizard/tax_receipt_annual_create_view.xml",
"wizard/tax_receipt_print_view.xml",
],
}
12 changes: 12 additions & 0 deletions donation_certificate/data/donation_sequence.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="donation_seq" model="ir.sequence">
<field name="name">Donation</field>
<field name="code">donation.donation</field>
<field name="prefix">DON-%(range_year)s-</field>
<field name="padding">4</field>
<field name="use_date_range" eval="True" />
</record>

</odoo>
45 changes: 45 additions & 0 deletions donation_certificate/data/mail_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" ?>
<odoo>
<!-- Comments: Todavia no sé qué estructura debería tener, pero si hay algun sugerencia la añado -->
<record id="email_template_donation_certificate" model="mail.template">
<field name="name">Donation: Certificate</field>
<field name="model_id" ref="donation.model_donation_tax_receipt" />
<field name="auto_delete" eval="True" />
<field name="email_from">{{ object.company_id.email }}</field>
<field name="email_to">{{ object.partner_id.email }}</field>
<field name="subject">Donation Certificate</field>
<field name="description">Donation Certificate</field>
<field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Dear
<t t-out="object.partner_id.name or ''">Donor name</t>,
<br />
<br />
We want to express our sincere gratitude for your generous donation of
<span
style="font-weight:bold;"
t-out="format_amount(object.amount, object.currency_id) or ''"
>$ 143,750.00</span>
to our organization. This contribution is a testament to your commitment and trust in our work.
<br />
<br />
With this collaboration you help us move forward with our mission. We sincerely appreciate your support.
<br />
<br />
Cordially,
<br />
<br />
<t t-out="object.company_id.name or ''">
--
<br />
Association name
</t>
</p>
</div>
</field>

<field name="lang">{{ object.partner_id.lang }}</field>
<field name="report_name">Donation Certificate</field>
</record>
</odoo>
36 changes: 36 additions & 0 deletions donation_certificate/data/py3o_certificate_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="py3o_template_certificate_ES" model="py3o.template">
<field name="name">Donation Certificate ES</field>
<field name="filetype">odt</field>
<field
name="py3o_template_fallback"
>report/PDA34_Certificat_de_donacions_ES.odt</field>
</record>

<record id="py3o_template_certificate_CAT" model="py3o.template">
<field name="name">Donation Certificate CAT</field>
<field name="filetype">odt</field>
<field
name="py3o_template_fallback"
>report/PDA34_Certificat_de_donacions_CAT.odt</field>
</record>

<record id="py3o_template_certificate_FR" model="py3o.template">
<field name="name">Donation Certificate FR</field>
<field name="filetype">odt</field>
<field
name="py3o_template_fallback"
>report/PDA34_Certificat_de_donacions_FR.odt</field>
</record>

<record id="py3o_template_certificate_EN" model="py3o.template">
<field name="name">Donation Certificate EN</field>
<field name="filetype">odt</field>
<field
name="py3o_template_fallback"
>report/PDA34_Certificat_de_donacions_EN.odt</field>
</record>

</odoo>
4 changes: 4 additions & 0 deletions donation_certificate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import py3o_report
from . import py3o_template
from . import donation
from . import donation_tax_receipt
77 changes: 77 additions & 0 deletions donation_certificate/models/donation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from odoo import _, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import get_lang


class Donation(models.Model):
_inherit = "donation.donation"

is_certificate_send = fields.Boolean(
help="This field automatically becomes active when "
"the thanks letter has been send.",
)
attachment_ids = fields.One2many(
"ir.attachment",
"res_id",
domain=[("res_model", "=", "donation.donation")],
string="Attachments",
)

def action_send_certificate(self):
self.ensure_one()
if not self.tax_receipt_id and self.tax_receipt_option == "annual":
raise ValidationError(_("Annual receipt has not been generated yet."))
self.write({"is_certificate_send": True})
template = self.env.ref(self._get_mail_template(), raise_if_not_found=False)
lang = False
if template:
lang = template._render_lang(self.ids)[self.id]
if not lang:
lang = get_lang(self.env).code
compose_form = self.env.ref(
"donation_certificate.donation_certificate_send_wizard_form",
raise_if_not_found=False,
)
ctx = dict(
default_model="donation.tax.receipt",
default_res_id=self.tax_receipt_id.id,
default_res_model="donation.tax.receipt",
default_use_template=bool(template),
default_template_id=template and template.id or False,
default_composition_mode="comment",
mark_invoice_as_sent=True,
default_email_layout_xmlid=(
"mail.mail_notification_layout_with_responsible_signature"
),
force_email=True,
active_ids=self.tax_receipt_id.ids,
)
report_action = {
"name": _("Send Certificate"),
"type": "ir.actions.act_window",
"view_type": "form",
"view_mode": "form",
"res_model": "donation.certificate.send",
"views": [(compose_form.id, "form")],
"view_id": compose_form.id,
"target": "new",
"context": ctx,
}
return report_action

def action_print_tax_receipt(self):
"""Print the certificate and mark it as sent, so that we can see more
easily the next step of the workflow
"""
self.filtered(lambda r: not r.is_certificate_send).write(
{"is_certificate_send": True}
)
return self.env.ref(
"donation_certificate.donation_certificate_report_py3o"
).report_action(self)

def _get_mail_template(self):
"""
:return: the correct mail template based on the current move type
"""
return "donation_certificate.email_template_donation_certificate"
Loading
Loading