diff --git a/account_spread_cost_revenue/README.rst b/account_spread_cost_revenue/README.rst index 8b6d7adf..2a389c3d 100644 --- a/account_spread_cost_revenue/README.rst +++ b/account_spread_cost_revenue/README.rst @@ -14,13 +14,13 @@ Cost-Revenue Spread :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github - :target: https://github.com/OCA/account-financial-tools/tree/11.0/account_spread_cost_revenue + :target: https://github.com/OCA/account-financial-tools/tree/12.0/account_spread_cost_revenue :alt: OCA/account-financial-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-financial-tools-11-0/account-financial-tools-11-0-account_spread_cost_revenue + :target: https://translation.odoo-community.org/projects/account-financial-tools-12-0/account-financial-tools-12-0-account_spread_cost_revenue :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/92/11.0 + :target: https://runbot.odoo-community.org/runbot/92/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -48,9 +48,23 @@ In the same *Account Spread* tab, you can also configure the Spread Balance Shee * the *Default Spread Account for Revenues*, * the *Default Spread Account for Expenses*. +This module by default allows the spreading even before the receipt of the invoice or when the invoice is still draft, +so that it is possible to work on the plan of the cost/revenue spreading. To disable this feature, on the form view of +the company disable the *Allow Spread Planning* option. + +On the form view of the company, the *Auto-post spread lines* option forces the account moves created +during the cost/revenue spreading to be automatically posted. When this option is false, the user can +enable/disable the automatic posting by the flag *Auto-post lines* present in the spread board. + +On the form view of the company, enable the *Auto-archive spread* option if you want the +cron job to automatically archive the spreads when all lines are posted. + Usage ===== +Define Spread Costs/Revenues Board +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Under Invoicing -> Adviser -> Accounting Entries -> Spread Costs/Revenues, create a new spread board. Complete the definition of the spreading criteria, by setting the the fields: @@ -63,25 +77,32 @@ Complete the definition of the spreading criteria, by setting the the fields: * *Start date* * *Journal* -.. figure:: static/description/spread.png +.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/spread.png :alt: Create a new spread board Click on the button on the top-left to calculate the spread lines. -.. figure:: static/description/create_spread.png +.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/create_spread.png :alt: The spreading board is defined A cron job will automatically create the accounting moves for all the lines having date previous that the current day (today). -.. figure:: static/description/update_spread.png +.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/update_spread.png :alt: The spreading board is updated by the cron job -By default, the status of the created accounting moves is unposted, so you should post them manually one by one. -To allow the automatic posting of the accounting moves, set the flag *Auto-post lines* to True. +By default, the status of the created accounting moves is posted. +To disable the automatic posting of the accounting moves, set the flag *Auto-post lines* to False. +This flag is only available when the *Auto-post spread lines* option, present on the form view of the company, is disabled. + +Click on button *Recalculate entire spread* button in the spread board to force the recalculation of the spread lines: +this will also reset all the journal entries previously created. + +Link Invoice to Spread Costs/Revenues Board +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create an invoice or vendor bill in draft. On its lines, the spreading right-arrow icon are displayed in dark-grey color. -.. figure:: static/description/invoice_line_1.png +.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/invoice_line_1.png :alt: On the invoice line the spreading icon is displayed Click on the spreading right-arrow icon. A wizard prompts to enter a *Spread Action Type*: @@ -96,7 +117,7 @@ the selected Spread Board will be automatically displayed. Go back to the draft invoice/bill. The spreading functionality is now enabled on the invoice line: the spreading right-arrow icon is now displayed in green color. -.. figure:: static/description/invoice_line_2.png +.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/invoice_line_2.png :alt: On the invoice line the spreading icon is displayed in green color Validate the invoice/bill. Click on the spreading (green) right-arrow icon to open the spread board, then click @@ -105,14 +126,32 @@ on the smart button *Reconciled entries*: the moves of the spread lines are reco In case the Subtotal Price of the invoice line is different than the *Estimated Amount* of the spread board, the spread lines (not yet posted) will be recalculated when validating the invoice/bill. -Click on button *Recalculate entire spread* button in the spread board to force the recalculation of the spread lines: -this will also reset all the journal entries previously created. +Define Spread Costs/Revenues Template +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Known issues / Roadmap -====================== +Under Invoicing -> Configuration -> Accounting -> Spread Templates, create a new spread template. -* Verify last day of month -* Not yet compatible with cutoff module: create module for adaptation? +* *Spread Type* +* *Spread Balance Sheet Account* +* *Journal* + +When creating a new Spread Costs/Revenues Board, select the right template. +This way the above fields will be copied to the Spread Board. + +Changelog +========= + +12.0.1.0.0 +~~~~~~~~~~ + +* [MIG] Port account_spread_cost_revenue to V12. + + +11.0.1.0.0 +~~~~~~~~~~ + +* [ADD] Module account_spread_cost_revenue. + (`#715 `_) Bug Tracker =========== @@ -120,7 +159,7 @@ 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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -165,6 +204,6 @@ Current `maintainer `__: |maintainer-astirpe| -This module is part of the `OCA/account-financial-tools `_ project on GitHub. +This module is part of the `OCA/account-financial-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_spread_cost_revenue/models/account_spread.py b/account_spread_cost_revenue/models/account_spread.py index 46b80692..d4e9c2c9 100644 --- a/account_spread_cost_revenue/models/account_spread.py +++ b/account_spread_cost_revenue/models/account_spread.py @@ -68,6 +68,9 @@ class AccountSpread(models.Model): total_amount = fields.Float( digits=dp.get_precision('Account'), compute='_compute_amounts') + all_posted = fields.Boolean( + compute='_compute_amounts', + store=True) line_ids = fields.One2many( 'account.spread.line', 'spread_id', @@ -123,6 +126,7 @@ class AccountSpread(models.Model): display_move_line_auto_post = fields.Boolean( compute='_compute_display_move_line_auto_post', string='Display Button Auto-post lines') + active = fields.Boolean(default=True) @api.model def default_get(self, fields): @@ -181,6 +185,7 @@ class AccountSpread(models.Model): spread.unposted_amount = total_amount - posted_amount spread.posted_amount = posted_amount spread.total_amount = total_amount + spread.all_posted = spread.unposted_amount == 0.0 @api.multi def _compute_display_create_all_moves(self): diff --git a/account_spread_cost_revenue/models/account_spread_line.py b/account_spread_cost_revenue/models/account_spread_line.py index b5b986db..9b9b40f0 100644 --- a/account_spread_cost_revenue/models/account_spread_line.py +++ b/account_spread_cost_revenue/models/account_spread_line.py @@ -166,3 +166,8 @@ class AccountInvoiceSpreadLine(models.Model): 'move_id').filtered(lambda m: m.state != 'posted') unposted_moves.filtered( lambda m: m.company_id.force_move_auto_post).post() + + spreads_to_archive = self.env['account.spread'].search([ + ('all_posted', '=', True) + ]).filtered(lambda s: s.company_id.auto_archive) + spreads_to_archive.write({'active': False}) diff --git a/account_spread_cost_revenue/models/res_company.py b/account_spread_cost_revenue/models/res_company.py index 8f5239e1..8b5d17eb 100644 --- a/account_spread_cost_revenue/models/res_company.py +++ b/account_spread_cost_revenue/models/res_company.py @@ -27,3 +27,7 @@ class ResCompany(models.Model): 'Auto-post spread lines', help="Enable this option if you want to post automatically the " "accounting moves of all the spreads.") + auto_archive = fields.Boolean( + 'Auto-archive spread', + help="Enable this option if you want the cron job to automatically " + "archive the spreads when all lines are posted.") diff --git a/account_spread_cost_revenue/readme/CONFIGURE.rst b/account_spread_cost_revenue/readme/CONFIGURE.rst index d216dc31..594bb201 100644 --- a/account_spread_cost_revenue/readme/CONFIGURE.rst +++ b/account_spread_cost_revenue/readme/CONFIGURE.rst @@ -18,3 +18,6 @@ the company disable the *Allow Spread Planning* option. On the form view of the company, the *Auto-post spread lines* option forces the account moves created during the cost/revenue spreading to be automatically posted. When this option is false, the user can enable/disable the automatic posting by the flag *Auto-post lines* present in the spread board. + +On the form view of the company, enable the *Auto-archive spread* option if you want the +cron job to automatically archive the spreads when all lines are posted. diff --git a/account_spread_cost_revenue/static/description/index.html b/account_spread_cost_revenue/static/description/index.html index 01247ace..8c2a91ab 100644 --- a/account_spread_cost_revenue/static/description/index.html +++ b/account_spread_cost_revenue/static/description/index.html @@ -367,26 +367,35 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

Allows to spread costs or revenues over a customizable periods, to even out cost or invoice spikes.

Table of contents

-

Configuration

+

Configuration

To be able to access the full spreading features, the user must belong to Show Full Accounting Features group.

On the form view of the company, in the Account Spread tab, you can configure the journals in which the spread journal items will be generated by default:

@@ -399,9 +408,19 @@ the journals in which the spread journal items will be generated by default:

  • the Default Spread Account for Revenues,
  • the Default Spread Account for Expenses.
  • +

    This module by default allows the spreading even before the receipt of the invoice or when the invoice is still draft, +so that it is possible to work on the plan of the cost/revenue spreading. To disable this feature, on the form view of +the company disable the Allow Spread Planning option.

    +

    On the form view of the company, the Auto-post spread lines option forces the account moves created +during the cost/revenue spreading to be automatically posted. When this option is false, the user can +enable/disable the automatic posting by the flag Auto-post lines present in the spread board.

    +

    On the form view of the company, enable the Auto-archive spread option if you want the +cron job to automatically archive the spreads when all lines are posted.

    -

    Usage

    +

    Usage

    +
    +

    Define Spread Costs/Revenues Board

    Under Invoicing -> Adviser -> Accounting Entries -> Spread Costs/Revenues, create a new spread board.

    Complete the definition of the spreading criteria, by setting the the fields:

      @@ -414,21 +433,27 @@ the journals in which the spread journal items will be generated by default:

    • Journal
    -Create a new spread board +Create a new spread board

    Click on the button on the top-left to calculate the spread lines.

    -The spreading board is defined +The spreading board is defined

    A cron job will automatically create the accounting moves for all the lines having date previous that the current day (today).

    -The spreading board is updated by the cron job +The spreading board is updated by the cron job
    -

    By default, the status of the created accounting moves is unposted, so you should post them manually one by one. -To allow the automatic posting of the accounting moves, set the flag Auto-post lines to True.

    +

    By default, the status of the created accounting moves is posted. +To disable the automatic posting of the accounting moves, set the flag Auto-post lines to False. +This flag is only available when the Auto-post spread lines option, present on the form view of the company, is disabled.

    +

    Click on button Recalculate entire spread button in the spread board to force the recalculation of the spread lines: +this will also reset all the journal entries previously created.

    +
    + -
    -

    Known issues / Roadmap

    +
    +

    Define Spread Costs/Revenues Template

    +

    Under Invoicing -> Configuration -> Accounting -> Spread Templates, create a new spread template.

      -
    • Verify last day of month
    • -
    • Not yet compatible with cutoff module: create module for adaptation?
    • +
    • Spread Type
    • +
    • Spread Balance Sheet Account
    • +
    • Journal
    • +
    +

    When creating a new Spread Costs/Revenues Board, select the right template. +This way the above fields will be copied to the Spread Board.

    +
    +
    +
    +

    Changelog

    +
    +

    12.0.1.0.0

    +
      +
    • [MIG] Port account_spread_cost_revenue to V12.
    +
    +

    11.0.1.0.0

    +
      +
    • [ADD] Module account_spread_cost_revenue. +(#715)
    • +
    +
    +
    -

    Bug Tracker

    +

    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 smashing it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • Onestein
    -

    Other credits

    +

    Other credits

    Part of the code in this module (in particular the computation of the spread lines) is highly inspired by the Assets Management module from the standard Odoo 11.0 Community developed by Odoo SA.

    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association

    OCA, or the Odoo Community Association, is a nonprofit organization whose @@ -494,7 +538,7 @@ mission is to support the collaborative development of Odoo features and promote its widespread use.

    Current maintainer:

    astirpe

    -

    This module is part of the OCA/account-financial-tools project on GitHub.

    +

    This module is part of the OCA/account-financial-tools project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/account_spread_cost_revenue/tests/test_account_invoice_spread.py b/account_spread_cost_revenue/tests/test_account_invoice_spread.py index 57a3d9c1..1e3a6e4e 100644 --- a/account_spread_cost_revenue/tests/test_account_invoice_spread.py +++ b/account_spread_cost_revenue/tests/test_account_invoice_spread.py @@ -4,7 +4,7 @@ import datetime from odoo.tools import convert_file -from odoo.modules.module import get_module_resource +from odoo.modules.module import get_resource_path from odoo.exceptions import UserError, ValidationError from odoo.tests import common @@ -15,7 +15,7 @@ class TestAccountInvoiceSpread(common.TransactionCase): convert_file( self.cr, 'account_spread_cost_revenue', - get_module_resource(module, *args), + get_resource_path(module, *args), {}, 'init', False, 'test', self.registry._assertion_report) def setUp(self): diff --git a/account_spread_cost_revenue/tests/test_account_spread_cost_revenue.py b/account_spread_cost_revenue/tests/test_account_spread_cost_revenue.py index e928860c..bba39f09 100644 --- a/account_spread_cost_revenue/tests/test_account_spread_cost_revenue.py +++ b/account_spread_cost_revenue/tests/test_account_spread_cost_revenue.py @@ -6,7 +6,7 @@ import datetime from psycopg2 import IntegrityError from odoo.tools import convert_file, mute_logger -from odoo.modules.module import get_module_resource +from odoo.modules.module import get_resource_path from odoo.exceptions import ValidationError from odoo.tests import common @@ -17,7 +17,7 @@ class TestAccountSpreadCostRevenue(common.TransactionCase): convert_file( self.cr, 'account_spread_cost_revenue', - get_module_resource(module, *args), + get_resource_path(module, *args), {}, 'init', False, 'test', self.registry._assertion_report) def setUp(self): diff --git a/account_spread_cost_revenue/views/account_spread.xml b/account_spread_cost_revenue/views/account_spread.xml index fd283b9d..a2de275e 100644 --- a/account_spread_cost_revenue/views/account_spread.xml +++ b/account_spread_cost_revenue/views/account_spread.xml @@ -19,6 +19,12 @@ type="object" string="Reconciled entries"> +