From 4e5b8fee4d139690f9924028defe991754cf114d Mon Sep 17 00:00:00 2001 From: Antoni Marroig Campomar Date: Thu, 2 May 2024 16:10:56 +0200 Subject: [PATCH] [IMP] account_spread_cost_revenue: pre-commit auto fixes --- account_spread_cost_revenue/README.rst | 225 ++++++++++-------- .../models/account_move_line.py | 2 +- .../models/account_spread.py | 14 +- .../models/account_spread_line.py | 2 +- account_spread_cost_revenue/pyproject.toml | 3 + .../readme/CONFIGURE.md | 34 +++ .../readme/CONFIGURE.rst | 25 -- .../readme/CONTRIBUTORS.md | 3 + .../readme/CONTRIBUTORS.rst | 3 - account_spread_cost_revenue/readme/CREDITS.md | 3 + .../readme/CREDITS.rst | 3 - .../{DESCRIPTION.rst => DESCRIPTION.md} | 3 +- account_spread_cost_revenue/readme/HISTORY.md | 23 ++ .../readme/HISTORY.rst | 28 --- account_spread_cost_revenue/readme/USAGE.md | 89 +++++++ account_spread_cost_revenue/readme/USAGE.rst | 79 ------ .../static/description/index.html | 144 ++++++----- .../tests/test_account_invoice_auto_spread.py | 3 - .../tests/test_account_invoice_spread.py | 9 - ...account_spread_invoice_line_link_wizard.py | 7 +- 20 files changed, 378 insertions(+), 324 deletions(-) create mode 100644 account_spread_cost_revenue/pyproject.toml create mode 100644 account_spread_cost_revenue/readme/CONFIGURE.md delete mode 100644 account_spread_cost_revenue/readme/CONFIGURE.rst create mode 100644 account_spread_cost_revenue/readme/CONTRIBUTORS.md delete mode 100644 account_spread_cost_revenue/readme/CONTRIBUTORS.rst create mode 100644 account_spread_cost_revenue/readme/CREDITS.md delete mode 100644 account_spread_cost_revenue/readme/CREDITS.rst rename account_spread_cost_revenue/readme/{DESCRIPTION.rst => DESCRIPTION.md} (64%) create mode 100644 account_spread_cost_revenue/readme/HISTORY.md delete mode 100644 account_spread_cost_revenue/readme/HISTORY.rst create mode 100644 account_spread_cost_revenue/readme/USAGE.md delete mode 100644 account_spread_cost_revenue/readme/USAGE.rst diff --git a/account_spread_cost_revenue/README.rst b/account_spread_cost_revenue/README.rst index 3eb378f4e..4dbec81b3 100644 --- a/account_spread_cost_revenue/README.rst +++ b/account_spread_cost_revenue/README.rst @@ -17,18 +17,19 @@ 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/16.0/account_spread_cost_revenue + :target: https://github.com/OCA/account-financial-tools/tree/17.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-16-0/account-financial-tools-16-0-account_spread_cost_revenue + :target: https://translation.odoo-community.org/projects/account-financial-tools-17-0/account-financial-tools-17-0-account_spread_cost_revenue :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -Allows to spread costs or revenues over a customizable periods, to even out cost or invoice spikes. +Allows to spread costs or revenues over a customizable periods, to even +out cost or invoice spikes. **Table of contents** @@ -38,146 +39,174 @@ Allows to spread costs or revenues over a customizable periods, to even out cost Configuration ============= -To be able to access the full spreading features, the user must belong to *Show Full Accounting Features* group. +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: +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: -* the *Default Spread Journal for Revenues*, -* the *Default Spread Journal for Expenses*. +- the *Default Spread Journal for Revenues*, +- the *Default Spread Journal for Expenses*. -In the same *Account Spread* tab, you can also configure the Spread Balance Sheet Accounts used by default: +In the same *Account Spread* tab, you can also configure the Spread +Balance Sheet Accounts used by default: -* the *Default Spread Account for Revenues*, -* the *Default Spread Account for Expenses*. +- 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. +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. -In Spread Template, there is also option to *Auto assign template on invoice validate*, based on the preset invoice line criteria. +In Spread Template, there is also option to *Auto assign template on +invoice validate*, based on the preset invoice line criteria. -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, 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. +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 -> Accounting -> Journals -> Spread Costs/Revenues, create a new spread board. +Under Invoicing -> Accounting -> Journals -> Spread Costs/Revenues, +create a new spread board. -Complete the definition of the spreading criteria, by setting the the fields: +Complete the definition of the spreading criteria, by setting the the +fields: -* *Debit Account* -* *Credit Account* -* *Estimated Amount* (The total amount to spread) -* *Number of Repetitions* -* *Period Type* (Duration of each period) -* *Start date* -* *Journal* +- *Debit Account* +- *Credit Account* +- *Estimated Amount* (The total amount to spread) +- *Number of Repetitions* +- *Period Type* (Duration of each period) +- *Start date* +- *Journal* -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/spread.png - :alt: Create a new spread board +|image1| -Click on the "Recalculate unposted lines" button on the top-left to calculate the spread lines. +Click on the "Recalculate unposted lines" button on the top-left to +calculate the spread lines. -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/create_spread.png - :alt: The spreading board is defined +|image2| -A cron job will automatically create the accounting moves for all the lines having date previous that the current day (today). +A cron job will automatically create the accounting moves for all the +lines having date previous that the current day (today). -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/update_spread.png - :alt: The spreading board is updated by the cron job +|image3| -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. +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. +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. +Create an invoice or vendor bill in draft. On its lines, the spreading +right-arrow icon are displayed in dark-grey color. -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/invoice_line_1.png - :alt: On the invoice line the spreading icon is displayed +|image4| -Click on the spreading right-arrow icon. A wizard prompts to enter a *Spread Action Type*: +Click on the spreading right-arrow icon. A wizard prompts to enter a +*Spread Action Type*: -- *Link to existing spread board* -- *Create from spread template* -- *Create new spread board* +- *Link to existing spread board* +- *Create from spread template* +- *Create new spread board* -Select *Link to existing spread board* and enter the previously generated Spread Board. Click on Confirm button: -the selected Spread Board will be automatically displayed. +Select *Link to existing spread board* and enter the previously +generated Spread Board. Click on Confirm button: 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. +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:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/invoice_line_2.png - :alt: On the invoice line the spreading icon is displayed in green color +|image5| -Validate the invoice/bill. Click on the spreading (green) right-arrow icon to open the spread board, then click -on the smart button *Posted entries* to see the moves of the spread lines together with the move of the invoice line. +Validate the invoice/bill. Click on the spreading (green) right-arrow +icon to open the spread board, then click on the smart button *Posted +entries* to see the moves of the spread lines together with the move of +the invoice line. -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. +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. Define Spread Costs/Revenues Template -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------------- -Under Invoicing -> Configuration -> Accounting -> Spread Templates, create a new spread template. +Under Invoicing -> Configuration -> Accounting -> Spread Templates, +create a new spread template. -* *Spread Type* -* *Spread Balance Sheet Account* -* *Expense/Revenue Account* This option visible if invoice line account is balance sheet account, user need to specify this too. -* *Journal* -* *Auto assign template on invoice validate* +- *Spread Type* +- *Spread Balance Sheet Account* +- *Expense/Revenue Account* This option visible if invoice line account + is balance sheet account, user need to specify this too. +- *Journal* +- *Auto assign template on invoice validate* -When creating a new Spread Costs/Revenues Board, select the right template. -This way the above fields will be copied to the Spread Board. +When creating a new Spread Costs/Revenues Board, select the right +template. This way the above fields will be copied to the Spread Board. -If *Auto assign template on invoice validate* is checked, this template will be used to auto create spread, if the underlining invoice match the preset product/account/analytic criteria. +If *Auto assign template on invoice validate* is checked, this template +will be used to auto create spread, if the underlining invoice match the +preset product/account/analytic criteria. + +.. |image1| image:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/spread.png +.. |image2| image:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/create_spread.png +.. |image3| image:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/update_spread.png +.. |image4| image:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/invoice_line_1.png +.. |image5| image:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/invoice_line_2.png Changelog ========= 13.0.1.0.0 -~~~~~~~~~~ +---------- -* [MIG] Port account_spread_cost_revenue to V13. +- [MIG] Port account_spread_cost_revenue to V13. 12.0.2.0.0 -~~~~~~~~~~ +---------- -* [ENH] In spread template, add option to auto create spread on invoice validation +- [ENH] In spread template, add option to auto create spread on invoice + validation 12.0.1.1.0 -~~~~~~~~~~ - -* [ENH] Add optional Expense/Revenue Account in Chart Template, which can be used - in place of account from invoice line to set Expense/Revenue account in the spread +---------- +- [ENH] Add optional Expense/Revenue Account in Chart Template, which + can be used in place of account from invoice line to set + Expense/Revenue account in the spread 12.0.1.0.0 -~~~~~~~~~~ - -* [MIG] Port account_spread_cost_revenue to V12. +---------- +- [MIG] Port account_spread_cost_revenue to V12. 11.0.1.0.0 -~~~~~~~~~~ +---------- -* [ADD] Module account_spread_cost_revenue. - (`#715 `_) +- [ADD] Module account_spread_cost_revenue. + (`#715 `__) Bug Tracker =========== @@ -185,7 +214,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 to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -193,26 +222,26 @@ Credits ======= Authors -~~~~~~~ +------- * Onestein Contributors -~~~~~~~~~~~~ +------------ -* Andrea Stirpe -* Kitti U. -* Saran Lim. +- Andrea Stirpe +- Kitti U. +- Saran Lim. 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. +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 -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -224,6 +253,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -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_move_line.py b/account_spread_cost_revenue/models/account_move_line.py index 2091927a1..55591745c 100644 --- a/account_spread_cost_revenue/models/account_move_line.py +++ b/account_spread_cost_revenue/models/account_move_line.py @@ -96,7 +96,7 @@ class AccountMoveLine(models.Model): def _check_spread_reconcile_validity(self): # Improve error messages of standard Odoo - reconciled_lines = self.filtered(lambda l: l.reconciled) + reconciled_lines = self.filtered(lambda x: x.reconciled) msg_line = _( "Move line: %(line_id)s (%(line_name)s), account code: %(account_code)s\n" ) diff --git a/account_spread_cost_revenue/models/account_spread.py b/account_spread_cost_revenue/models/account_spread.py index a0ae07bef..152c54270 100644 --- a/account_spread_cost_revenue/models/account_spread.py +++ b/account_spread_cost_revenue/models/account_spread.py @@ -194,9 +194,9 @@ class AccountSpread(models.Model): ) def _compute_amounts(self): for spread in self: - lines_move = spread.line_ids.filtered(lambda l: l.move_id) + lines_move = spread.line_ids.filtered(lambda x: x.move_id) moves_amount = sum(spread_line.amount for spread_line in lines_move) - lines_posted = lines_move.filtered(lambda l: l.move_id.state == "posted") + lines_posted = lines_move.filtered(lambda x: x.move_id.state == "posted") posted_amount = sum(spread_line.amount for spread_line in lines_posted) total_amount = spread.estimated_amount if spread.invoice_line_id: @@ -368,7 +368,7 @@ class AccountSpread(models.Model): posted_line_ids = self.line_ids.filtered( lambda x: x.move_id.state == "posted" - ).sorted(key=lambda l: l.date) + ).sorted(key=lambda x: x.date) unposted_line_ids = self.line_ids.filtered( lambda x: not x.move_id.state == "posted" ) @@ -570,7 +570,7 @@ class AccountSpread(models.Model): spread_mls |= created_moves.mapped("line_ids") account = self.invoice_line_id.account_id - mls_to_reconcile = spread_mls.filtered(lambda l: l.account_id == account) + mls_to_reconcile = spread_mls.filtered(lambda x: x.account_id == account) if mls_to_reconcile: do_reconcile = mls_to_reconcile + self.invoice_line_ids @@ -578,17 +578,17 @@ class AccountSpread(models.Model): for line in do_reconcile: line.reconciled = False # ensure to reconcile only posted items - do_reconcile = do_reconcile.filtered(lambda l: l.move_id.state == "posted") + do_reconcile = do_reconcile.filtered(lambda x: x.move_id.state == "posted") do_reconcile._check_spread_reconcile_validity() do_reconcile.reconcile() def create_all_moves(self): - for line in self.mapped("line_ids").filtered(lambda l: not l.move_id): + for line in self.mapped("line_ids").filtered(lambda x: not x.move_id): line.create_move() def _post_spread_moves(self, moves): self.ensure_one() - moves = moves.filtered(lambda l: l.state != "posted") + moves = moves.filtered(lambda x: x.state != "posted") if not moves: return ctx = dict(self.env.context, skip_unique_sequence_number=True) diff --git a/account_spread_cost_revenue/models/account_spread_line.py b/account_spread_cost_revenue/models/account_spread_line.py index e8d9bca15..a2b6d815b 100644 --- a/account_spread_cost_revenue/models/account_spread_line.py +++ b/account_spread_cost_revenue/models/account_spread_line.py @@ -45,7 +45,7 @@ class AccountInvoiceSpreadLine(models.Model): ).create_and_reconcile_moves() def _create_moves(self): - if self.filtered(lambda l: l.move_id): + if self.filtered(lambda x: x.move_id): raise UserError( _( "This spread line is already linked to a " diff --git a/account_spread_cost_revenue/pyproject.toml b/account_spread_cost_revenue/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/account_spread_cost_revenue/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_spread_cost_revenue/readme/CONFIGURE.md b/account_spread_cost_revenue/readme/CONFIGURE.md new file mode 100644 index 000000000..158845bfe --- /dev/null +++ b/account_spread_cost_revenue/readme/CONFIGURE.md @@ -0,0 +1,34 @@ +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: + +- the *Default Spread Journal for Revenues*, +- the *Default Spread Journal for Expenses*. + +In the same *Account Spread* tab, you can also configure the Spread +Balance Sheet Accounts used 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. + +In Spread Template, there is also option to *Auto assign template on +invoice validate*, based on the preset invoice line criteria. + +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/readme/CONFIGURE.rst b/account_spread_cost_revenue/readme/CONFIGURE.rst deleted file mode 100644 index 6a5cca1d6..000000000 --- a/account_spread_cost_revenue/readme/CONFIGURE.rst +++ /dev/null @@ -1,25 +0,0 @@ -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: - -* the *Default Spread Journal for Revenues*, -* the *Default Spread Journal for Expenses*. - -In the same *Account Spread* tab, you can also configure the Spread Balance Sheet Accounts used 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. - -In Spread Template, there is also option to *Auto assign template on invoice validate*, based on the preset invoice line criteria. - -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/readme/CONTRIBUTORS.md b/account_spread_cost_revenue/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..545ddf38f --- /dev/null +++ b/account_spread_cost_revenue/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Andrea Stirpe \<\> +- Kitti U. \<\> +- Saran Lim. \<\> diff --git a/account_spread_cost_revenue/readme/CONTRIBUTORS.rst b/account_spread_cost_revenue/readme/CONTRIBUTORS.rst deleted file mode 100644 index 926463864..000000000 --- a/account_spread_cost_revenue/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,3 +0,0 @@ -* Andrea Stirpe -* Kitti U. -* Saran Lim. diff --git a/account_spread_cost_revenue/readme/CREDITS.md b/account_spread_cost_revenue/readme/CREDITS.md new file mode 100644 index 000000000..28c0790b2 --- /dev/null +++ b/account_spread_cost_revenue/readme/CREDITS.md @@ -0,0 +1,3 @@ +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. diff --git a/account_spread_cost_revenue/readme/CREDITS.rst b/account_spread_cost_revenue/readme/CREDITS.rst deleted file mode 100644 index 9a3666a47..000000000 --- a/account_spread_cost_revenue/readme/CREDITS.rst +++ /dev/null @@ -1,3 +0,0 @@ -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. diff --git a/account_spread_cost_revenue/readme/DESCRIPTION.rst b/account_spread_cost_revenue/readme/DESCRIPTION.md similarity index 64% rename from account_spread_cost_revenue/readme/DESCRIPTION.rst rename to account_spread_cost_revenue/readme/DESCRIPTION.md index d37dce994..a7da0dad3 100644 --- a/account_spread_cost_revenue/readme/DESCRIPTION.rst +++ b/account_spread_cost_revenue/readme/DESCRIPTION.md @@ -1 +1,2 @@ -Allows to spread costs or revenues over a customizable periods, to even out cost or invoice spikes. +Allows to spread costs or revenues over a customizable periods, to even +out cost or invoice spikes. diff --git a/account_spread_cost_revenue/readme/HISTORY.md b/account_spread_cost_revenue/readme/HISTORY.md new file mode 100644 index 000000000..4065d75c1 --- /dev/null +++ b/account_spread_cost_revenue/readme/HISTORY.md @@ -0,0 +1,23 @@ +## 13.0.1.0.0 + +- \[MIG\] Port account_spread_cost_revenue to V13. + +## 12.0.2.0.0 + +- \[ENH\] In spread template, add option to auto create spread on + invoice validation + +## 12.0.1.1.0 + +- \[ENH\] Add optional Expense/Revenue Account in Chart Template, which + can be used in place of account from invoice line to set + Expense/Revenue account in the spread + +## 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](https://github.com/OCA/account-financial-tools/pull/715)) diff --git a/account_spread_cost_revenue/readme/HISTORY.rst b/account_spread_cost_revenue/readme/HISTORY.rst deleted file mode 100644 index 0f78ececc..000000000 --- a/account_spread_cost_revenue/readme/HISTORY.rst +++ /dev/null @@ -1,28 +0,0 @@ -13.0.1.0.0 -~~~~~~~~~~ - -* [MIG] Port account_spread_cost_revenue to V13. - -12.0.2.0.0 -~~~~~~~~~~ - -* [ENH] In spread template, add option to auto create spread on invoice validation - -12.0.1.1.0 -~~~~~~~~~~ - -* [ENH] Add optional Expense/Revenue Account in Chart Template, which can be used - in place of account from invoice line to set Expense/Revenue account in the spread - - -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 `_) diff --git a/account_spread_cost_revenue/readme/USAGE.md b/account_spread_cost_revenue/readme/USAGE.md new file mode 100644 index 000000000..e4e3b89a9 --- /dev/null +++ b/account_spread_cost_revenue/readme/USAGE.md @@ -0,0 +1,89 @@ +## Define Spread Costs/Revenues Board + +Under Invoicing -\> Accounting -\> Journals -\> Spread Costs/Revenues, +create a new spread board. + +Complete the definition of the spreading criteria, by setting the the +fields: + +- *Debit Account* +- *Credit Account* +- *Estimated Amount* (The total amount to spread) +- *Number of Repetitions* +- *Period Type* (Duration of each period) +- *Start date* +- *Journal* + +![](https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/spread.png) + +Click on the "Recalculate unposted lines" button on the top-left to +calculate the spread lines. + +![](https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/create_spread.png) + +A cron job will automatically create the accounting moves for all the +lines having date previous that the current day (today). + +![](https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/update_spread.png) + +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. + +![](https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/invoice_line_1.png) + +Click on the spreading right-arrow icon. A wizard prompts to enter a +*Spread Action Type*: + +- *Link to existing spread board* +- *Create from spread template* +- *Create new spread board* + +Select *Link to existing spread board* and enter the previously +generated Spread Board. Click on Confirm button: 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. + +![](https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/invoice_line_2.png) + +Validate the invoice/bill. Click on the spreading (green) right-arrow +icon to open the spread board, then click on the smart button *Posted +entries* to see the moves of the spread lines together with the move of +the invoice line. + +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. + +## Define Spread Costs/Revenues Template + +Under Invoicing -\> Configuration -\> Accounting -\> Spread Templates, +create a new spread template. + +- *Spread Type* +- *Spread Balance Sheet Account* +- *Expense/Revenue Account* This option visible if invoice line account + is balance sheet account, user need to specify this too. +- *Journal* +- *Auto assign template on invoice validate* + +When creating a new Spread Costs/Revenues Board, select the right +template. This way the above fields will be copied to the Spread Board. + +If *Auto assign template on invoice validate* is checked, this template +will be used to auto create spread, if the underlining invoice match the +preset product/account/analytic criteria. diff --git a/account_spread_cost_revenue/readme/USAGE.rst b/account_spread_cost_revenue/readme/USAGE.rst deleted file mode 100644 index 3737e4b7d..000000000 --- a/account_spread_cost_revenue/readme/USAGE.rst +++ /dev/null @@ -1,79 +0,0 @@ -Define Spread Costs/Revenues Board -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Under Invoicing -> Accounting -> Journals -> Spread Costs/Revenues, create a new spread board. - -Complete the definition of the spreading criteria, by setting the the fields: - -* *Debit Account* -* *Credit Account* -* *Estimated Amount* (The total amount to spread) -* *Number of Repetitions* -* *Period Type* (Duration of each period) -* *Start date* -* *Journal* - -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_spread_cost_revenue/static/description/spread.png - :alt: Create a new spread board - -Click on the "Recalculate unposted lines" button on the top-left to calculate the spread lines. - -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.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:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.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 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:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.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*: - -- *Link to existing spread board* -- *Create from spread template* -- *Create new spread board* - -Select *Link to existing spread board* and enter the previously generated Spread Board. Click on Confirm button: -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:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.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 -on the smart button *Posted entries* to see the moves of the spread lines together with the move of the invoice line. - -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. - -Define Spread Costs/Revenues Template -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Under Invoicing -> Configuration -> Accounting -> Spread Templates, create a new spread template. - -* *Spread Type* -* *Spread Balance Sheet Account* -* *Expense/Revenue Account* This option visible if invoice line account is balance sheet account, user need to specify this too. -* *Journal* -* *Auto assign template on invoice validate* - -When creating a new Spread Costs/Revenues Board, select the right template. -This way the above fields will be copied to the Spread Board. - -If *Auto assign template on invoice validate* is checked, this template will be used to auto create spread, if the underlining invoice match the preset product/account/analytic criteria. diff --git a/account_spread_cost_revenue/static/description/index.html b/account_spread_cost_revenue/static/description/index.html index c84f5c6b4..70d24490a 100644 --- a/account_spread_cost_revenue/static/description/index.html +++ b/account_spread_cost_revenue/static/description/index.html @@ -368,8 +368,9 @@ ul.auto-toc { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:cdfa137e88f59eb3720e56fa4e3fa998ae4b44e0f1f2795726134dc53abc7fc5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

-

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

+

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

+

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

Table of contents

    @@ -400,34 +401,45 @@ ul.auto-toc {

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:

+

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:

  • the Default Spread Journal for Revenues,
  • the Default Spread Journal for Expenses.
-

In the same Account Spread tab, you can also configure the Spread Balance Sheet Accounts used by default:

+

In the same Account Spread tab, you can also configure the Spread +Balance Sheet Accounts used 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.

-

In Spread Template, there is also option to Auto assign template on invoice validate, based on the preset invoice line criteria.

-

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.

+

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.

+

In Spread Template, there is also option to Auto assign template on +invoice validate, based on the preset invoice line criteria.

+

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 -> Accounting -> Journals -> Spread Costs/Revenues, create a new spread board.

-

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

+

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

+

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

  • Debit Account
  • Credit Account
  • @@ -437,60 +449,66 @@ cron job to automatically archive the spreads when all lines are posted.

  • Start date
  • Journal
-
-Create a new spread board -
-

Click on the “Recalculate unposted lines” button on the top-left to calculate the spread lines.

-
-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 -
-

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.

+

image1

+

Click on the “Recalculate unposted lines” button on the top-left to +calculate the spread lines.

+

image2

+

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

+

image3

+

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.

Define Spread Costs/Revenues Template

-

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

+

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

  • Spread Type
  • Spread Balance Sheet Account
  • -
  • Expense/Revenue Account This option visible if invoice line account is balance sheet account, user need to specify this too.
  • +
  • Expense/Revenue Account This option visible if invoice line account +is balance sheet account, user need to specify this too.
  • Journal
  • Auto assign template on invoice validate
-

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

-

If Auto assign template on invoice validate is checked, this template will be used to auto create spread, if the underlining invoice match the preset product/account/analytic criteria.

+

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

+

If Auto assign template on invoice validate is checked, this template +will be used to auto create spread, if the underlining invoice match the +preset product/account/analytic criteria.

@@ -504,14 +522,16 @@ This way the above fields will be copied to the Spread Board.

12.0.2.0.0

    -
  • [ENH] In spread template, add option to auto create spread on invoice validation
  • +
  • [ENH] In spread template, add option to auto create spread on invoice +validation

12.0.1.1.0

    -
  • [ENH] Add optional Expense/Revenue Account in Chart Template, which can be used -in place of account from invoice line to set Expense/Revenue account in the spread
  • +
  • [ENH] Add optional Expense/Revenue Account in Chart Template, which +can be used in place of account from invoice line to set +Expense/Revenue account in the spread
@@ -533,7 +553,7 @@ in place of account from invoice line to set Expense/Revenue account in the spre

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.

+feedback.

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

@@ -554,9 +574,9 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

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.

+

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

@@ -565,7 +585,7 @@ Odoo 11.0 Community developed by Odoo SA.

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

-

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_auto_spread.py b/account_spread_cost_revenue/tests/test_account_invoice_auto_spread.py index fd770372e..189cf0460 100644 --- a/account_spread_cost_revenue/tests/test_account_invoice_auto_spread.py +++ b/account_spread_cost_revenue/tests/test_account_invoice_auto_spread.py @@ -8,7 +8,6 @@ from .test_account_invoice_spread import TestAccountInvoiceSpread class TestAccountInvoiceAutoSpread(TestAccountInvoiceSpread): def test_01_no_auto_spread_sheet(self): - self.env["account.spread.template"].create( { "name": "test", @@ -29,7 +28,6 @@ class TestAccountInvoiceAutoSpread(TestAccountInvoiceSpread): self.assertFalse(self.vendor_bill_line.spread_id) def test_02_new_auto_spread_sheet_purchase(self): - self.env["account.spread.template"].create( { "name": "test 1", @@ -75,7 +73,6 @@ class TestAccountInvoiceAutoSpread(TestAccountInvoiceSpread): self.assertTrue(line.move_id) def test_03_new_auto_spread_sheet_sale(self): - self.env["account.spread.template"].create( { "name": "test", 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 4ab88ce4c..5cf41e15a 100644 --- a/account_spread_cost_revenue/tests/test_account_invoice_spread.py +++ b/account_spread_cost_revenue/tests/test_account_invoice_spread.py @@ -246,7 +246,6 @@ class TestAccountInvoiceSpread(common.TransactionCase): self.assertTrue(wizard2.spread_invoice_type_domain_ids) def test_03_link_invoice_line_with_spread_sheet(self): - self.env.user.write( { "groups_id": [ @@ -295,7 +294,6 @@ class TestAccountInvoiceSpread(common.TransactionCase): self.assertTrue(self.spread.invoice_line_id) def test_04_new_spread_sheet(self): - Wizard = self.env["account.spread.invoice.line.link.wizard"] spread_journal_id = self.expenses_journal @@ -364,7 +362,6 @@ class TestAccountInvoiceSpread(common.TransactionCase): self.assertTrue(line.move_id) def test_05_new_spread_sheet_from_template(self): - Wizard = self.env["account.spread.invoice.line.link.wizard"] spread_account = self.account_payable @@ -433,14 +430,12 @@ class TestAccountInvoiceSpread(common.TransactionCase): self.assertTrue(line.move_id) def test_06_open_wizard(self): - res_action = self.vendor_bill_line.spread_details() self.assertTrue(isinstance(res_action, dict)) self.assertFalse(res_action.get("res_id")) self.assertTrue(res_action.get("context")) def test_07_unlink_invoice_line_and_spread_sheet(self): - self.assertFalse(self.spread.invoice_line_id) self.vendor_bill_line.spread_id = self.spread @@ -492,7 +487,6 @@ class TestAccountInvoiceSpread(common.TransactionCase): ) def test_09_no_link_invoice(self): - balance_sheet = self.spread.credit_account_id # Validate invoice @@ -637,7 +631,6 @@ class TestAccountInvoiceSpread(common.TransactionCase): self.assertTrue(action_spread_details.get("res_id")) def test_12_link_invoice_line_with_spread_sheet_full_reconcile(self): - # Validate invoice self.sale_invoice.action_post() @@ -692,7 +685,6 @@ class TestAccountInvoiceSpread(common.TransactionCase): self.assertTrue(action_spread_details.get("res_id")) def test_13_link_invoice_line_with_spread_sheet_partial_reconcile(self): - self.spread2.write( { "estimated_amount": 1000.0, @@ -784,7 +776,6 @@ class TestAccountInvoiceSpread(common.TransactionCase): self.spread.unlink() def test_15_invoice_refund(self): - self.vendor_bill_line.spread_id = self.spread # Validate invoice diff --git a/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.py b/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.py index 487a01d12..172550ac8 100644 --- a/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.py +++ b/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.py @@ -202,10 +202,9 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel): date_invoice = date_invoice or fields.Date.today() spread_vals["spread_date"] = date_invoice - spread_vals["name"] = ("%s %s") % ( - spread_vals["name"], - self.invoice_line_id.name, - ) + spread_vals[ + "name" + ] = f"({spread_vals['name']} { self.invoice_line_id.name})" if spread_vals["invoice_type"] == "out_invoice": spread_vals["credit_account_id"] = account.id