-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add module for Off-balance accounting (#224)
* add off balance feature for sponsorship accounting * off balance spn module * add readme
- Loading branch information
Showing
7 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/CompassionCH/test-repo/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/test-repo/issues/new?body=module:%20account_statement_completion%0Aversion:%2014.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 | ||
|
||
Contributors | ||
------------ | ||
|
||
- Steve Ferry <[email protected]> | ||
- Emanuel Cino <[email protected]> | ||
- Quentin Gigon <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is part of the `CompassionCH/test-repo <https://github.com/CompassionCH/test-repo/tree/14.0/account_statement_completion>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
############################################################################## | ||
# | ||
# ______ Releasing children from poverty _ | ||
# / ____/___ ____ ___ ____ ____ ___________(_)___ ____ | ||
# / / / __ \/ __ `__ \/ __ \/ __ `/ ___/ ___/ / __ \/ __ \ | ||
# / /___/ /_/ / / / / / / /_/ / /_/ (__ |__ ) / /_/ / / / / | ||
# \____/\____/_/ /_/ /_/ .___/\__,_/____/____/_/\____/_/ /_/ | ||
# /_/ | ||
# in Jesus' name | ||
# | ||
# Copyright (C) 2014-today Compassion CH (http://www.compassion.ch) | ||
# @author: David Wulliamoz <[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/>. | ||
# | ||
############################################################################## | ||
|
||
{ | ||
'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', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import bank_statement_line | ||
from . import res_config |
39 changes: 39 additions & 0 deletions
39
account_offbalance_sponsorship/models/bank_statement_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
# | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
############################################################################## | ||
# | ||
# Copyright (C) 2014-today Compassion CH (http://www.compassion.ch) | ||
# Releasing children from poverty in Jesus' name | ||
# @author: David Wulliamoz <[email protected]> | ||
# | ||
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="view_account_off_balance_setting" model="ir.ui.view"> | ||
<field name="name">Offbalance accounting settings</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="message_center_compassion.compassion_settings"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div[@name='compassion_settings']"> | ||
<h2>Sponsorship off-balance accounting settings</h2> | ||
<div class="row mt16 o_settings_container"> | ||
<div class="col-xs-12 col-md-12 o_setting_box"> | ||
<div class="o_setting_right_pane"> | ||
<div class="row"> | ||
<label class="col-md-5 o_light_label" for="account_offbalance_receivable"/> | ||
<field name="account_offbalance_receivable"/> | ||
</div> | ||
<div class="row"> | ||
<label class="col-md-5 o_light_label" for="account_offbalance_asset"/> | ||
<field name="account_offbalance_asset"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |