diff --git a/account_offbalance_sponsorship/README.rst b/account_offbalance_sponsorship/README.rst new file mode 100644 index 00000000..383464a8 --- /dev/null +++ b/account_offbalance_sponsorship/README.rst @@ -0,0 +1,68 @@ +================================== +Off balance sponsorship accounting +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:eb5f5892e8010671bcfb91746ecfef8a321631e5d4e9671fdbe069f42e30c369 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Ftest--repo-lightgray.png?logo=github + :target: https://github.com/CompassionCH/test-repo/tree/14.0/account_statement_completion + :alt: CompassionCH/test-repo + +|badge1| |badge2| |badge3| + +This module adds a way to implement off-balance sponsorship accounting. +Sponsorship generate invoices to enable off balance accounting (which can be required in certain legislation) +we cannot rely on the odoo off-balance account feature (it does not allow a reconcilable account) +2 accounts are defined in the sponsorship config: Account asset and an reconcilable account. +This enable to have the full set of accounts from invoice generation to payment, all off the main chart of account. + +The income to be reported in the accounting is to be done in batch, once payments are in. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Compassion CH + +Contributors +------------ + +- Steve Ferry +- Emanuel Cino +- Quentin Gigon + +Maintainers +----------- + +This module is part of the `CompassionCH/test-repo `_ project on GitHub. + +You are welcome to contribute. diff --git a/account_offbalance_sponsorship/__init__.py b/account_offbalance_sponsorship/__init__.py new file mode 100644 index 00000000..511a0ca3 --- /dev/null +++ b/account_offbalance_sponsorship/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import controllers +from . import models \ No newline at end of file diff --git a/account_offbalance_sponsorship/__manifest__.py b/account_offbalance_sponsorship/__manifest__.py new file mode 100644 index 00000000..fe87959d --- /dev/null +++ b/account_offbalance_sponsorship/__manifest__.py @@ -0,0 +1,69 @@ +############################################################################## +# +# ______ Releasing children from poverty _ +# / ____/___ ____ ___ ____ ____ ___________(_)___ ____ +# / / / __ \/ __ `__ \/ __ \/ __ `/ ___/ ___/ / __ \/ __ \ +# / /___/ /_/ / / / / / / /_/ / /_/ (__ |__ ) / /_/ / / / / +# \____/\____/_/ /_/ /_/ .___/\__,_/____/____/_/\____/_/ /_/ +# /_/ +# in Jesus' name +# +# Copyright (C) 2014-today Compassion CH (http://www.compassion.ch) +# @author: David Wulliamoz +# +# 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 . +# +############################################################################## + +{ + 'name': "account_offbalance_sponsorship", + + 'summary': """ + Off-Balance accounting for sponsorships. +""", + + 'description': """ + It's not possible to use the stock off-balance feature because + it's not possible to have a reconciliable off-balance account. So we use the 9xxx account and a configuration to + define: + - receivable (off-balance): A + - asset (off-balance): B + this function adds in the payment move if there is an off-balance (A) receivable account: + - the off-balance asset (B) + - add the outstanding account again. """, + + 'author': "Compassion CH", + 'website': "http://www.compassion.ch", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/data/ir_module_category_data.xml + # for the full list + 'category': 'sponsorship and donation', + 'version': '0.1', + + # any module necessary for this one to work correctly + 'depends': ['base', + 'sponsorship_compassion', + ], + + # always loaded + 'data': [ + # 'security/ir.model.access.csv', + 'views/res_config_view.xml', + ], + # only loaded in demonstration mode + 'demo': [ + 'demo/demo.xml', + ], +} diff --git a/account_offbalance_sponsorship/models/__init__.py b/account_offbalance_sponsorship/models/__init__.py new file mode 100644 index 00000000..6211f7d2 --- /dev/null +++ b/account_offbalance_sponsorship/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import bank_statement_line +from . import res_config diff --git a/account_offbalance_sponsorship/models/bank_statement_line.py b/account_offbalance_sponsorship/models/bank_statement_line.py new file mode 100644 index 00000000..7df0fa6e --- /dev/null +++ b/account_offbalance_sponsorship/models/bank_statement_line.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014-today Compassion CH (http://www.compassion.ch) +# Releasing children from poverty in Jesus' name +# @author: David Wulliamoz +# +# The licence is in the file __manifest__.py +# +############################################################################## + +import logging +from functools import reduce + +from odoo import _, models +class BankStatementLine(models.Model): + _inherit = "account.bank.statement.line" + + def _create_counterpart_and_new_aml(self, counterpart_moves, counterpart_aml_dicts, new_aml_dicts): + """ + With these two lines, all the donations accounting can be off-balance. + + the real income is to be booked (once a month) in a batch move, from the outstanding account to the different income account + """ + res = super()._create_counterpart_and_new_aml(counterpart_moves, counterpart_aml_dicts, new_aml_dicts) + + company = res.company_id + param_obj = self.env["res.config.settings"].sudo().with_company(company) + account_offbalance_receivable = (param_obj.get_param("account_offbalance_receivable")) + account_offbalance_asset = (param_obj.get_param("account_offbalance_asset")) + if account_offbalance_receivable in res.line_ids.mapped("account_id.id"): + self.move_id.line_ids += ( + self.env["account.move.line"].with_context(check_move_validity=False).create( + {"account_id": account_offbalance_asset, "move_id": res.id, "debit": self.amount, + "credit": 0} + ) + self.env["account.move.line"].with_context(check_move_validity=False).create( + {"account_id": res.journal_id.payment_debit_account_id.id, "move_id": res.id, "debit": 0, + "credit": self.amount})) + return res diff --git a/account_offbalance_sponsorship/models/res_config.py b/account_offbalance_sponsorship/models/res_config.py new file mode 100644 index 00000000..4a926db3 --- /dev/null +++ b/account_offbalance_sponsorship/models/res_config.py @@ -0,0 +1,49 @@ +############################################################################## +# +# Copyright (C) 2014-today Compassion CH (http://www.compassion.ch) +# Releasing children from poverty in Jesus' name +# @author: David Wulliamoz +# +# The licence is in the file __manifest__.py +# +############################################################################## + +from odoo import fields, models,api + +class OffBalanceAccountConfigSettings(models.TransientModel): + """ + Add the possibility to define an off balance asset account and and off balance receivable account + """ + + _inherit = "res.config.settings" + + account_offbalance_receivable = fields.Many2one( + "account.account", readonly=False + ) + account_offbalance_asset = fields.Many2one( + "account.account", readonly=False + ) + + @api.model + def get_values(self): + res = super().get_values() + company_id = self.env.company.id + config = self.env["ir.config_parameter"].sudo() + res["account_offbalance_receivable"] = int( + config.get_param(f"account_offbalance_receivable_{company_id}", default="0") + ) + res["account_offbalance_asset"] = int( + config.get_param(f"account_offbalance_asset_{company_id}", default="0") + ) + return res + + @api.model + def set_values(self): + company_id = self.env.company.id + self.env["ir.config_parameter"].set_param( + f"account_offbalance_receivable_{company_id}", self.account_offbalance_receivable.id + ) + self.env["ir.config_parameter"].set_param( + f"account_offbalance_asset_{company_id}", self.account_offbalance_asset.id + ) + super().set_values() diff --git a/account_offbalance_sponsorship/views/res_config_view.xml b/account_offbalance_sponsorship/views/res_config_view.xml new file mode 100644 index 00000000..840aba50 --- /dev/null +++ b/account_offbalance_sponsorship/views/res_config_view.xml @@ -0,0 +1,27 @@ + + + + Offbalance accounting settings + res.config.settings + + + +

Sponsorship off-balance accounting settings

+
+
+
+
+
+
+
+
+
+
+
+
+
+