-
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.
Merge pull request #64 from CompassionCH/devel
Devel to prod
- Loading branch information
Showing
35 changed files
with
1,286 additions
and
45 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
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
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,12 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2018 Compassion CH (http://www.compassion.ch) | ||
# Releasing children from poverty in Jesus' name | ||
# @author: Nicolas Bornand | ||
# | ||
# The licence is in the file __manifest__.py | ||
# | ||
############################################################################## | ||
|
||
from . import test_analytic_attribution |
109 changes: 109 additions & 0 deletions
109
account_analytic_attribution/tests/test_analytic_attribution.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,109 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2018 Compassion CH (http://www.compassion.ch) | ||
# Releasing children from poverty in Jesus' name | ||
# @author: Nicolas Bornand | ||
# | ||
# The licence is in the file __manifest__.py | ||
# | ||
############################################################################## | ||
import logging | ||
from datetime import datetime, timedelta | ||
from odoo import fields | ||
from odoo.tests.common import TransactionCase | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class TestAnalyticAttribution(TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestAnalyticAttribution, self).setUp() | ||
self.analytic_account = self.env["account.analytic.account"] \ | ||
.create({"name": "Test Account"}) | ||
self.account = self.env["account.account"] \ | ||
.search([('code', '=', '1050')]) | ||
self.tag = self.env.ref('account_analytic_attribution.tag_attribution') | ||
self.Attribution = self.env['account.analytic.attribution'] | ||
|
||
def test_perform_distribution__line_generation(self): | ||
self._create_line_with_amount_twelve(self.analytic_account) | ||
self._create_line_with_amount_twelve(self.analytic_account) | ||
attribution = self.Attribution.create({}) | ||
self.env['account.analytic.distribution.line'].create({ | ||
'rate': 40, | ||
'account_analytic_id': self.analytic_account.id, | ||
'attribution_id': attribution.id | ||
}) | ||
|
||
self._assert_analytic_lines_count(2) | ||
line = attribution.perform_distribution() | ||
self._assert_analytic_lines_count(3) | ||
|
||
self.assertEqual(len(line), 1) | ||
self.assertAlmostEqual(line.amount, 9.6) # 40% of (2*12) | ||
self.assertEqual(line.account_id.id, self.analytic_account.id) | ||
self.assertTrue('Analytic attribution for' in line.name) | ||
|
||
def test_perform_distribution__should_evict_old_analytic_lines(self): | ||
line = self._create_line_with_amount_twelve(self.analytic_account) | ||
line.tag_ids += self.env \ | ||
.ref('account_analytic_attribution.tag_attribution') | ||
attribution = self.Attribution.create({}) | ||
|
||
self._assert_analytic_lines_count(1) | ||
attribution.perform_distribution() | ||
self._assert_analytic_lines_count(0) | ||
|
||
def test_get_attribution__match_if_filters_are_not_set(self): | ||
attribution = self.Attribution.create({}) | ||
self.env['account.analytic.distribution.line'].create({ | ||
'rate': 40, | ||
'account_analytic_id': self.analytic_account.id, | ||
'attribution_id': attribution.id | ||
}) | ||
|
||
matched = attribution.get_attribution(False, False, datetime.now()) | ||
self.assertEqual(len(matched), 1) | ||
|
||
def test_get_attribution__matching_by_date(self): | ||
attribution = self.Attribution.create({ | ||
'rate': 40, | ||
'date_start': datetime.now(), | ||
'date_stop': datetime.now() | ||
}) | ||
|
||
yesterday = datetime.now() - timedelta(days=-1) | ||
rules = attribution.get_attribution(False, False, yesterday) | ||
self.assertEqual(len(rules), 0) | ||
|
||
matched = attribution.get_attribution(False, False, datetime.now()) | ||
self.assertEqual(len(matched), 1) | ||
|
||
def test_get_attribution__matching_by_tag(self): | ||
attribution = self.Attribution.create({ | ||
'rate': 40 | ||
}) | ||
attribution.analytic_tag_id += self.tag | ||
|
||
now = datetime.now() | ||
unknown_tag = 99 | ||
rules = attribution.get_attribution(False, [unknown_tag], now) | ||
self.assertEqual(len(rules), 0) | ||
|
||
matched = attribution.get_attribution(False, [self.tag.id], now) | ||
self.assertEqual(len(matched), 1) | ||
|
||
def _create_line_with_amount_twelve(self, account): | ||
return self.env['account.analytic.line'].create({ | ||
'name': 'test line', | ||
'amount': 12.0, | ||
'account_id': account.id, | ||
'general_account_id': 1, | ||
'date': fields.Datetime.from_string('2017-05-05') | ||
}) | ||
|
||
def _assert_analytic_lines_count(self, count): | ||
lines_after = self.env['account.analytic.line'].search([]) | ||
self.assertEqual(len(lines_after), count) |
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
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,70 @@ | ||
=========================================== | ||
Account move open bills to next fiscal year | ||
=========================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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--accounting-lightgray.png?logo=github | ||
:target: https://github.com/CompassionCH/compassion-accounting/tree/10.0/account_move_fiscalyear | ||
:alt: CompassionCH/compassion-accounting | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This module adds an option to automatically move open customer invoice moves to the next fiscal year during the fiscal year closing. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
In the Accounting Settings menu, in the Fiscal Year section, enable the option "Move unclosed bills to next fiscal year" to enable the feature. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/CompassionCH/compassion-accounting/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/CompassionCH/compassion-accounting/issues/new?body=module:%20account_move_fiscalyear%0Aversion:%2010.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 | ||
~~~~~~~~~~~~ | ||
|
||
* Quentin Gigon <[email protected]> | ||
* Emanuel Cino <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by Compassion Switzerland. | ||
|
||
.. image:: https://upload.wikimedia.org/wikipedia/en/8/83/CompassionInternationalLogo.png | ||
:alt: Compassion Switzerland | ||
:target: https://www.compassion.ch | ||
|
||
Compassion Switzerland is a nonprofit organization whose | ||
mission is to release children from extreme poverty in Jesus name. | ||
|
||
This module is part of the `CompassionCH/compassion-accounting <https://github.com/CompassionCH/compassion-accounting/tree/10.0/account_move_fiscalyear>`_ project on GitHub. |
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,10 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2018 Compassion CH (http://www.compassion.ch) | ||
# @author: Quentin Gigon <[email protected]> | ||
# | ||
# The licence is in the file __manifest__.py | ||
# | ||
############################################################################## | ||
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,23 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2018 Compassion CH (http://www.compassion.ch) | ||
# @author: Quentin Gigon <[email protected]> | ||
# | ||
# The licence is in the file __manifest__.py | ||
# | ||
############################################################################## | ||
# pylint: disable=C8101 | ||
{ | ||
'name': 'Account move open bills to next fiscal year', | ||
'version': '10.0.0.0.0', | ||
'license': 'AGPL-3', | ||
'author': 'Compassion CH', | ||
'website': 'http://www.compassion.ch', | ||
'category': 'Accounting', | ||
'depends': ['account'], | ||
'external_dependencies': {}, | ||
'data': ['views/res_config_bills_view.xml'], | ||
'demo': [], | ||
'installable': True, | ||
} |
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,12 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2018 Compassion CH (http://www.compassion.ch) | ||
# @author: Quentin Gigon <[email protected]> | ||
# | ||
# The licence is in the file __manifest__.py | ||
# | ||
############################################################################## | ||
|
||
from . import account_config_settings | ||
from . import res_company |
Oops, something went wrong.