From 058b9f91066ee4373cf041caf67e1455a6a38b01 Mon Sep 17 00:00:00 2001 From: Saran440 Date: Mon, 29 May 2023 10:38:12 +0700 Subject: [PATCH] [15.0][MIG] account_spread_cost_revenue --- account_spread_cost_revenue/README.rst | 28 +++-- account_spread_cost_revenue/__manifest__.py | 9 +- .../models/account_move_line.py | 22 +++- .../models/account_spread.py | 20 ++-- .../models/account_spread_template.py | 2 +- .../readme/CONTRIBUTORS.rst | 1 + account_spread_cost_revenue/readme/USAGE.rst | 4 +- .../security/account_spread_security.xml | 52 +++++---- .../static/description/index.html | 103 +++++++++--------- .../templates/assets.xml | 15 --- .../tests/test_account_invoice_spread.py | 1 + 11 files changed, 133 insertions(+), 124 deletions(-) delete mode 100644 account_spread_cost_revenue/templates/assets.xml diff --git a/account_spread_cost_revenue/README.rst b/account_spread_cost_revenue/README.rst index 6dbcfaf1d..e5ca11b3f 100644 --- a/account_spread_cost_revenue/README.rst +++ b/account_spread_cost_revenue/README.rst @@ -2,10 +2,13 @@ Cost-Revenue Spread =================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ce097fc5db396e4e0e101cf32d007468e93282cf26b6ae15de0e1cb103c01d0f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -14,16 +17,16 @@ 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/14.0/account_spread_cost_revenue + :target: https://github.com/OCA/account-financial-tools/tree/15.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-14-0/account-financial-tools-14-0-account_spread_cost_revenue + :target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-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/14.0 - :alt: Try me on Runbot +.. |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=15.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| Allows to spread costs or revenues over a customizable periods, to even out cost or invoice spikes. @@ -67,7 +70,7 @@ Usage Define Spread Costs/Revenues Board ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Under Invoicing -> Adviser -> Accounting Entries -> Spread Costs/Revenues, create a new spread board. +Under Invoicing -> Accounting -> Miscellaneous -> Spread Costs/Revenues, create a new spread board. Complete the definition of the spreading criteria, by setting the the fields: @@ -82,7 +85,7 @@ Complete the definition of the spreading criteria, by setting the the fields: .. 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. +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/12.0/account_spread_cost_revenue/static/description/create_spread.png :alt: The spreading board is defined @@ -181,8 +184,8 @@ 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 `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -199,6 +202,7 @@ Contributors * Andrea Stirpe * Kitti U. +* Saran Lim. Other credits ~~~~~~~~~~~~~ @@ -228,6 +232,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/__manifest__.py b/account_spread_cost_revenue/__manifest__.py index b1f3af7d3..da224121c 100644 --- a/account_spread_cost_revenue/__manifest__.py +++ b/account_spread_cost_revenue/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Cost-Revenue Spread", "summary": "Spread costs and revenues over a custom period", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "development_status": "Beta", "author": "Onestein,Odoo Community Association (OCA)", "maintainers": ["astirpe"], @@ -12,6 +12,12 @@ "website": "https://github.com/OCA/account-financial-tools", "category": "Accounting & Finance", "depends": ["account"], + "assets": { + "web.assets_backend": [ + "/account_spread_cost_revenue/static/src/scss/account_spread.scss", + "/account_spread_cost_revenue/static/src/js/account_spread.js", + ], + }, "data": [ "security/ir.model.access.csv", "security/account_spread_security.xml", @@ -19,7 +25,6 @@ "views/account_move.xml", "views/res_company.xml", "views/account_spread_template.xml", - "templates/assets.xml", "wizards/account_spread_invoice_line_link_wizard.xml", "data/spread_cron.xml", ], diff --git a/account_spread_cost_revenue/models/account_move_line.py b/account_spread_cost_revenue/models/account_move_line.py index c62089bd1..804136ae1 100644 --- a/account_spread_cost_revenue/models/account_move_line.py +++ b/account_spread_cost_revenue/models/account_move_line.py @@ -97,16 +97,26 @@ class AccountMoveLine(models.Model): def _check_spread_reconcile_validity(self): # Improve error messages of standard Odoo reconciled_lines = self.filtered(lambda l: l.reconciled) - msg_line = _("Move line: %s (%s), account code: %s\n") + msg_line = _( + "Move line: %(line_id)s (%(line_name)s), account code: %(account_code)s\n" + ) if reconciled_lines: msg = _("Cannot reconcile entries that are already reconciled:\n") for line in reconciled_lines: - msg += msg_line % (line.id, line.name, line.account_id.code) + msg += msg_line % { + "line_id": line.id, + "line_name": line.name, + "account_code": line.account_id.code, + } raise ValidationError(msg) if len(self.mapped("account_id").ids) > 1: msg = _("Some entries are not from the same account:\n") for line in self: - msg += msg_line % (line.id, line.name, line.account_id.code) + msg += msg_line % { + "line_id": line.id, + "line_name": line.name, + "account_code": line.account_id.code, + } raise ValidationError(msg) def create_auto_spread(self): @@ -146,10 +156,10 @@ class AccountMoveLine(models.Model): elif len(template) > 1: raise UserError( _( - "Too many auto spread templates (%s) matched with the " - "invoice line, %s" + "Too many auto spread templates (%(len_template)s) matched with the " + "invoice line, %(line_name)s" ) - % (len(template), line.display_name) + % {"len_template": len(template), "line_name": line.display_name} ) # Found auto spread template for this invoice line, create it wizard = self.env["account.spread.invoice.line.link.wizard"].new( diff --git a/account_spread_cost_revenue/models/account_spread.py b/account_spread_cost_revenue/models/account_spread.py index 445d732bc..8f8b6ec76 100644 --- a/account_spread_cost_revenue/models/account_spread.py +++ b/account_spread_cost_revenue/models/account_spread.py @@ -520,19 +520,21 @@ class AccountSpread(models.Model): "%s" % (spread.invoice_id.id, _("Invoice")) ) - msg_body = _("Unlinked invoice line '%s' (view %s).") % ( - spread.invoice_line_id.name, - inv_link, - ) + msg_body = _( + "Unlinked invoice line '%(spread_line_name)s' (view %(inv_link)s)." + ) % { + "spread_line_name": spread.invoice_line_id.name, + "inv_link": inv_link, + } spread.message_post(body=msg_body) spread_link = ( "%s" % (spread.id, _("Spread")) ) - msg_body = _("Unlinked '%s' (invoice line %s).") % ( - spread_link, - spread.invoice_line_id.name, - ) + msg_body = _("Unlinked '%(spread_link)s' (invoice line %(inv_line)s).") % { + "spread_link": spread_link, + "inv_line": spread.invoice_line_id.name, + } spread.invoice_id.message_post(body=msg_body) def unlink(self): @@ -578,7 +580,7 @@ class AccountSpread(models.Model): return ctx = dict(self.env.context, skip_unique_sequence_number=True) if self.company_id.force_move_auto_post or self.move_line_auto_post: - moves.with_context(ctx).action_post() + moves.with_context(**ctx).action_post() @api.depends("debit_account_id.deprecated", "credit_account_id.deprecated") def _compute_deprecated_accounts(self): diff --git a/account_spread_cost_revenue/models/account_spread_template.py b/account_spread_cost_revenue/models/account_spread_template.py index 090e76f6a..2fddd86ca 100644 --- a/account_spread_cost_revenue/models/account_spread_template.py +++ b/account_spread_cost_revenue/models/account_spread_template.py @@ -169,7 +169,7 @@ class AccountSpreadTemplate(models.Model): ) if results: raise UserError( - _("Followings are duplicated combinations,\n\n%s" % "\n".join(results)) + _("Followings are duplicated combinations,\n\n%s") % "\n".join(results) ) diff --git a/account_spread_cost_revenue/readme/CONTRIBUTORS.rst b/account_spread_cost_revenue/readme/CONTRIBUTORS.rst index db8766429..926463864 100644 --- a/account_spread_cost_revenue/readme/CONTRIBUTORS.rst +++ b/account_spread_cost_revenue/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Andrea Stirpe * Kitti U. +* Saran Lim. diff --git a/account_spread_cost_revenue/readme/USAGE.rst b/account_spread_cost_revenue/readme/USAGE.rst index 74dbb1d34..0acc072ba 100644 --- a/account_spread_cost_revenue/readme/USAGE.rst +++ b/account_spread_cost_revenue/readme/USAGE.rst @@ -1,7 +1,7 @@ Define Spread Costs/Revenues Board ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Under Invoicing -> Adviser -> Accounting Entries -> Spread Costs/Revenues, create a new spread board. +Under Invoicing -> Accounting -> Miscellaneous -> Spread Costs/Revenues, create a new spread board. Complete the definition of the spreading criteria, by setting the the fields: @@ -16,7 +16,7 @@ Complete the definition of the spreading criteria, by setting the the fields: .. 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. +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/12.0/account_spread_cost_revenue/static/description/create_spread.png :alt: The spreading board is defined diff --git a/account_spread_cost_revenue/security/account_spread_security.xml b/account_spread_cost_revenue/security/account_spread_security.xml index 99df6699a..5e453c0b1 100644 --- a/account_spread_cost_revenue/security/account_spread_security.xml +++ b/account_spread_cost_revenue/security/account_spread_security.xml @@ -1,29 +1,27 @@ - - - - Account Spread multi-company - - - ['|',('company_id','=',False),('company_id', 'in', company_ids)] - - - Account Spread Template multi-company - - - ['|',('company_id','=',False),('company_id', 'in', company_ids)] - - - Account Spread Tempalte Auto multi-company - - - ['|',('company_id','=',False),('company_id', 'in', company_ids)] - - + + + Account Spread multi-company + + + ['|',('company_id','=',False),('company_id', 'in', company_ids)] + + + Account Spread Template multi-company + + + ['|',('company_id','=',False),('company_id', 'in', company_ids)] + + + Account Spread Tempalte Auto multi-company + + + ['|',('company_id','=',False),('company_id', 'in', company_ids)] + diff --git a/account_spread_cost_revenue/static/description/index.html b/account_spread_cost_revenue/static/description/index.html index b391f5ae2..f32873202 100644 --- a/account_spread_cost_revenue/static/description/index.html +++ b/account_spread_cost_revenue/static/description/index.html @@ -1,20 +1,20 @@ - + - + Cost-Revenue Spread