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

[MIG] Rr/17.0 gift compassion #1983

Open
wants to merge 4 commits into
base: 17.0
Choose a base branch
from
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
8 changes: 7 additions & 1 deletion advanced_translation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@
"development_status": "Production/Stable",
"depends": ["base"],
"external_dependencies": {
"python": ["babel", "pytesseract", "langdetect", "iso639-lang", "pandas>=2.0.0"],
"python": [
"babel",
"pytesseract",
"langdetect",
"iso639-lang",
"pandas>=2.0.0",
],
},
"data": [
"security/ir.model.access.csv",
Expand Down
5 changes: 1 addition & 4 deletions child_compassion/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@
position="inside"
>
<setting id="disaster_alert_setting">
<field
name="disaster_notify_ids"
widget="many2many_tags"
/>
<field name="disaster_notify_ids" widget="many2many_tags" />
</setting>
</xpath>
</field>
Expand Down
57 changes: 57 additions & 0 deletions gift_compassion/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
============================
Compassion Sponsorship Gifts
============================

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

.. |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-CompassionCH%2Fcompassion--modules-lightgray.png?logo=github
:target: https://github.com/CompassionCH/compassion-modules/tree/17.0/gift_compassion
:alt: CompassionCH/compassion-modules

|badge1| |badge2| |badge3|

Compassion Gift Module

Setup models related to sponsorship's gift

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/CompassionCH/compassion-modules/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/CompassionCH/compassion-modules/issues/new?body=module:%20gift_compassion%0Aversion:%2017.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
-------

* Compassion CH

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

This module is part of the `CompassionCH/compassion-modules <https://github.com/CompassionCH/compassion-modules/tree/17.0/gift_compassion>`_ project on GitHub.

You are welcome to contribute.
20 changes: 20 additions & 0 deletions gift_compassion/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <[email protected]>
#
# The licence is in the file __manifest__.py
#
##############################################################################
from odoo.addons.message_center_compassion.tools.load_mappings import load_mapping_files

from . import models, wizards


def load_mappings(env):
path = "gift_compassion/static/mappings/"
files = [
"mapping.json",
]
load_mapping_files(env, path, files)
55 changes: 55 additions & 0 deletions gift_compassion/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
##############################################################################
#
# ______ Releasing children from poverty _
# / ____/___ ____ ___ ____ ____ ___________(_)___ ____
# / / / __ \/ __ `__ \/ __ \/ __ `/ ___/ ___/ / __ \/ __ \
# / /___/ /_/ / / / / / / /_/ / /_/ (__ |__ ) / /_/ / / / /
# \____/\____/_/ /_/ /_/ .___/\__,_/____/____/_/\____/_/ /_/
# /_/
# in Jesus' name
#
# Copyright (C) 2016-2017 Compassion CH (http://www.compassion.ch)
# @author: Emanuel Cino <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# pylint: disable=C8101
{
"name": "Compassion Sponsorship Gifts",
"version": "17.0.1.0.0",
"category": "Compassion",
"author": "Compassion CH",
"license": "AGPL-3",
"website": "https://github.com/CompassionCH/compassion-modules",
"depends": ["sponsorship_compassion"],
"data": [
"security/ir.model.access.csv",
"data/gift_thresholds.xml",
"data/process_gift_cron.xml",
"views/collect_gifts_wizard_view.xml",
"views/gift_view.xml",
"views/settings_view.xml",
"views/contracts_view.xml",
"data/gift_compassion_mapping.xml",
"data/gmc_action.xml",
"data/base_automation.xml",
],
"demo": [],
"installable": True,
"auto_install": False,
"post_init_hook": "load_mappings",
}

# pylint: disable=C8101
29 changes: 29 additions & 0 deletions gift_compassion/data/base_automation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<odoo>
<!-- Action Server update message state to new -->
<record id="action_enable_postponed_gifts" model="ir.actions.server">
<field name="name">Enable Postponed Gifts</field>
<field name="model_id" ref="model_sponsorship_gift" />
<field name="state">code</field>
<field name="usage">base_automation</field>
<field name="code">
records.mapped("message_id").write({"state": "new"})
</field>
</record>

<!-- Automation Rule to enable postponed gifts -->
<record model="base.automation" id="enable_postponed_gifts">
<field name="name">Enable postponed gifts</field>
<field name="model_id" ref="model_sponsorship_gift" />
<field name="trigger">on_time</field>
<field name="trg_date_id" ref="field_sponsorship_gift__gift_date" />
<field name="trg_date_range_type">minutes</field>
<field name="trg_date_range">0</field>
<field
name="filter_domain"
>[('state','!=','verify'),('message_id.state','=','postponed')]</field>
<field
name="action_server_ids"
eval="[(6, 0, [ref('action_enable_postponed_gifts')])]"
/>
</record>
</odoo>
6 changes: 6 additions & 0 deletions gift_compassion/data/gift_compassion_mapping.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<odoo>
<record id="mapping_create_update_gifts" model="compassion.mapping">
<field name="model_id" ref="model_sponsorship_gift" />
<field name="name">CreateGift</field>
</record>
</odoo>
46 changes: 46 additions & 0 deletions gift_compassion/data/gift_thresholds.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<odoo>
<!-- Gift Thresholds -->
<record id="gt-01" model="gift.threshold.settings">
<field name="gift_type">Beneficiary Gift</field>
<field name="gift_attribution">Sponsorship</field>
<field name="sponsorship_gift_type">Birthday</field>
<field name="min_amount">10</field>
<field name="max_amount">100</field>
<field name="gift_frequency">2</field>
<field name="yearly_threshold">true</field>
<field name="currency_id" ref="base.USD" />
</record>
<record id="gt-02" model="gift.threshold.settings">
<field name="gift_type">Beneficiary Gift</field>
<field name="gift_attribution">Sponsorship</field>
<field name="sponsorship_gift_type">General</field>
<field name="min_amount">10</field>
<field name="max_amount">100</field>
<field name="gift_frequency">2</field>
<field name="yearly_threshold">true</field>
<field name="currency_id" ref="base.USD" />
</record>
<record id="gt-03" model="gift.threshold.settings">
<field name="gift_type">Beneficiary Gift</field>
<field name="gift_attribution">Sponsorship</field>
<field name="sponsorship_gift_type">Graduation/Final</field>
<field name="min_amount">10</field>
<field name="max_amount">2000</field>
<field name="gift_frequency">1</field>
<field name="currency_id" ref="base.USD" />
</record>
<record id="gt-05" model="gift.threshold.settings">
<field name="gift_type">Family Gift</field>
<field name="gift_attribution">Sponsored Child Family</field>
<field name="min_amount">25</field>
<field name="max_amount">1000</field>
<field name="currency_id" ref="base.USD" />
</record>
<record id="gt-07" model="gift.threshold.settings">
<field name="gift_type">Project Gift</field>
<field name="gift_attribution">Center Based Programming</field>
<field name="min_amount">100</field>
<field name="max_amount">2000</field>
<field name="currency_id" ref="base.USD" />
</record>
</odoo>
39 changes: 39 additions & 0 deletions gift_compassion/data/gmc_action.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<odoo>
<data noupdate="1">
<!-- Create Gift Message -->
<record id="create_gift" model="gmc.action">
<field name="direction">out</field>
<field name="name">CreateGift</field>
<field name="mapping_id" ref="mapping_create_update_gifts" />
<field
name="success_method"
>on_gift_sent</field> <!-- par défaut : write-->
<field
name="description"
>This will trigger a Gift Creation at the Field.</field>
<field name="connect_service">supporters/gifts</field>
<field name="connect_outgoing_wrapper">GiftCreateRequestList</field>
<field
name="connect_answer_wrapper"
>GiftCreateResponses.GiftCreateResponseList</field>
<field name="request_type">POST</field>
</record>
<!-- Update Gift Message -->
<record id="update_gift" model="gmc.action">
<field name="direction">in</field>
<field name="name">UpdateGift</field>
<field name="mapping_id" ref="mapping_create_update_gifts" />
<field
name="description"
>This will trigger a Gift Update at the Field.</field>
<field name="auto_process">1</field>
</record>

<record id="update_gift_connect" model="gmc.action.connect">
<field
name="connect_schema"
>http://schemas.ci.org/ci/messaging/supporters/2016/04/GiftNotification</field>
<field name="action_id" ref="update_gift" />
</record>
</data>
</odoo>
14 changes: 14 additions & 0 deletions gift_compassion/data/process_gift_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<odoo>
<data noupdate="1">
<record id="process_gift_cron" model="ir.cron">
<field name="name">Process gifts</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="state">code</field>
<field name="code">model.process_gifts_cron()</field>
<field name="model_id" ref="model_sponsorship_gift" />
<field name="active" eval="False" />
</record>
</data>
</odoo>
19 changes: 19 additions & 0 deletions gift_compassion/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <[email protected]>
#
# The licence is in the file __manifest__.py
#
##############################################################################

from . import (
account_move,
account_move_line,
account_partial_reconcile,
contracts,
gift_threshold_settings,
recurring_contract_group,
sponsorship_gift,
)
19 changes: 19 additions & 0 deletions gift_compassion/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <[email protected]>
#
# The licence is in the file __manifest__.py
#
##############################################################################

from odoo import models


class AccountMove(models.Model):
_inherit = "account.move"

def button_cancel(self):
super().button_cancel()
self.mapped("invoice_line_ids.gift_id").unlink()
18 changes: 18 additions & 0 deletions gift_compassion/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <[email protected]>
#
# The licence is in the file __manifest__.py
#
##############################################################################
from odoo import fields, models


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

gift_id = fields.Many2one(
"sponsorship.gift", "GMC Gift", readonly=False, copy=False
)
37 changes: 37 additions & 0 deletions gift_compassion/models/account_partial_reconcile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##############################################################################
#
# Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <[email protected]>
#
# The licence is in the file __manifest__.py
#
##############################################################################
from odoo import _, models
from odoo.exceptions import UserError


class AccountPartialReconcile(models.Model):
_inherit = "account.partial.reconcile"

def unlink(self):
"""
Remove pending gifts or prevent unreconcile if gift are already sent.
"""
# This will retrieve all the lines of the reconciliation and the original move
lines = (self.mapped("debit_move_id") + self.mapped("credit_move_id")).mapped(
"move_id.line_ids"
)
for line in lines.filtered("gift_id"):
gift = line.gift_id
if gift.state in ["draft", "verify"]:
if gift.invoice_line_ids:
gift.write({"invoice_line_ids": [(3, line.id)]})
if not gift.invoice_line_ids:
gift.unlink()
elif gift.state != "Undeliverable":
raise UserError(
_("You cannot delete the %s. It is already sent to GMC.")
% gift.name
)
super().unlink()
Loading
Loading