diff --git a/account_cost_center/README.rst b/account_cost_center/README.rst index cbf7055b2e5..133fe87556f 100644 --- a/account_cost_center/README.rst +++ b/account_cost_center/README.rst @@ -17,13 +17,13 @@ Costcenter :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/15.0/account_cost_center + :target: https://github.com/OCA/account-financial-tools/tree/16.0/account_cost_center :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-15-0/account-financial-tools-15-0-account_cost_center + :target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_cost_center :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=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -47,14 +47,14 @@ Use the menu in the accounting module: **Configuration > Analytics accounting > Cost centers** -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/15.0/account_cost_center/static/description/account_costcenter_1.png +.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_cost_center/static/description/account_costcenter_1.png :alt: Cost centers can be configured :align: center Once defined you can add a cost center to an invoice line. A default cost center for the current invoice can be set in the other info tab. -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/15.0/account_cost_center/static/description/account_costcenter_2.png +.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_cost_center/static/description/account_costcenter_2.png :alt: Cost centers can be selected on invoice lines :align: center @@ -64,7 +64,7 @@ This module adds the cost center concept to the reporting. Here you can select or unselect the cost center within your analysis. -.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/15.0/account_cost_center/static/description/account_costcenter_3.png +.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_cost_center/static/description/account_costcenter_3.png :alt: Cost centers can be selected on invoice lines :align: center @@ -74,7 +74,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. @@ -93,6 +93,7 @@ Contributors * Richard Dijkstra * Andrea Stirpe * Antonio Esposito +* `Heliconia Solutions Pvt. Ltd. `_ Maintainers ~~~~~~~~~~~ @@ -107,6 +108,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_cost_center/__manifest__.py b/account_cost_center/__manifest__.py index b45aaacd354..14e6e47ac73 100644 --- a/account_cost_center/__manifest__.py +++ b/account_cost_center/__manifest__.py @@ -8,8 +8,8 @@ "license": "AGPL-3", "website": "https://github.com/OCA/account-financial-tools", "category": "Accounting", - "version": "15.0.1.0.0", - "depends": ["account"], + "version": "16.0.1.0.0", + "depends": ["account", "base_view_inheritance_extension"], "data": [ "security/ir.model.access.csv", "security/account_cost_center_security.xml", diff --git a/account_cost_center/readme/CONTRIBUTORS.rst b/account_cost_center/readme/CONTRIBUTORS.rst index c10c90a20ad..c1c0642d911 100644 --- a/account_cost_center/readme/CONTRIBUTORS.rst +++ b/account_cost_center/readme/CONTRIBUTORS.rst @@ -2,3 +2,4 @@ * Richard Dijkstra * Andrea Stirpe * Antonio Esposito +* `Heliconia Solutions Pvt. Ltd. `_ diff --git a/account_cost_center/static/description/index.html b/account_cost_center/static/description/index.html index 679fb4faa36..6af9d87a3f6 100644 --- a/account_cost_center/static/description/index.html +++ b/account_cost_center/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,7 +369,7 @@

Costcenter

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:697dce33e30296fb060a0f9fcb8be9b8807b5ba5c0d964de201ba90b34e53d24 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module allows the user to link every invoice line to a cost center providing an extra dimension for the analysis.

Table of contents

@@ -394,19 +394,19 @@

Usage

Configuration > Analytics accounting > Cost centers
-Cost centers can be configured +Cost centers can be configured

Once defined you can add a cost center to an invoice line. A default cost center for the current invoice can be set in the other info tab.

-Cost centers can be selected on invoice lines +Cost centers can be selected on invoice lines

This module adds the cost center concept to the reporting.

Accounting > Invoice Analysis

Here you can select or unselect the cost center within your analysis.

-Cost centers can be selected on invoice lines +Cost centers can be selected on invoice lines
@@ -414,7 +414,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.

@@ -432,16 +432,19 @@

Contributors

  • Richard Dijkstra <r.dijkstra@onestein.nl>
  • Andrea Stirpe <a.stirpe@onestein.nl>
  • Antonio Esposito <a.esposito@onestein.nl>
  • +
  • Heliconia Solutions Pvt. Ltd.
  • Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    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_cost_center/tests/test_cost_center.py b/account_cost_center/tests/test_cost_center.py index a34252a9677..fdb9d2afdde 100644 --- a/account_cost_center/tests/test_cost_center.py +++ b/account_cost_center/tests/test_cost_center.py @@ -11,14 +11,6 @@ class TestAccountCostCenter(AccountTestInvoicingCommon): @classmethod def setUpClass(cls, chart_template_ref=None): super().setUpClass(chart_template_ref=chart_template_ref) - cls.expenses_account = cls.env["account.account"].create( - { - "user_type_id": cls.env.ref("account.data_account_type_expenses").id, - "code": "EXPTEST", - "name": "Test expense account", - } - ) - cls.costcenter = cls.env["account.cost.center"].create( { "name": "Cost Center Test", @@ -73,12 +65,11 @@ def test_02_check_lines(self): line.name = "Test line2" line.quantity = 2.0 line.price_unit = 200.0 - line.account_id = self.expenses_account self.invoice1 = invoice_form.save() invoice_lines = self.invoice1.invoice_line_ids - self.assertFalse(any(line.cost_center_id for line in invoice_lines)) - self.assertTrue(any(not line.cost_center_id for line in invoice_lines)) + self.assertTrue(any(line.cost_center_id for line in invoice_lines)) + self.assertFalse(any(not line.cost_center_id for line in invoice_lines)) def test_03_confirm_invoice(self): invoice_lines = self.invoice2.invoice_line_ids @@ -96,3 +87,50 @@ def test_04_search_read(self): self.assertTrue(result) self.assertEqual(result[0], expected_cost_center.id) self.assertEqual(result[1], expected_cost_center.name) + + def test_05_default_cost_center_on_lines(self): + """The default cost center is selected when creating invoice lines""" + # Create an invoice: no default cost center is set + invoice = self.env["account.move"].create( + { + "partner_id": self.env.ref("base.res_partner_2").id, + "move_type": "in_invoice", + } + ) + self.assertFalse(invoice.cost_center_id) + + # Create an invoice line: no cost center is set + invoice_form = Form(invoice) + with invoice_form.invoice_line_ids.new() as line: + line.name = "Test line1" + line.quantity = 1.0 + line.price_unit = 100.0 + invoice_form.save() + self.assertEqual(len(invoice.invoice_line_ids), 1) + self.assertFalse(invoice.invoice_line_ids.cost_center_id) + + # Set a default cost center on invoice + invoice_form = Form(invoice) + invoice_form.cost_center_id = self.costcenter + + # Create an invoice line + with invoice_form.invoice_line_ids.new() as line: + line.name = "Test line2" + line.quantity = 2.0 + line.price_unit = 200.0 + invoice_form.save() + self.assertEqual(len(invoice.invoice_line_ids), 2) + + # Default cost center is set for new line + line_with_cost_center = invoice.invoice_line_ids.filtered( + lambda l: l.cost_center_id + ) + self.assertTrue(line_with_cost_center) + self.assertEqual(line_with_cost_center.cost_center_id, self.costcenter) + + # Default cost center stays not set for old line + line_no_cost_center = invoice.invoice_line_ids.filtered( + lambda l: not l.cost_center_id + ) + self.assertTrue(line_no_cost_center) + self.assertFalse(line_no_cost_center.cost_center_id) diff --git a/account_cost_center/views/account_move_line_views.xml b/account_cost_center/views/account_move_line_views.xml index c56fafff09a..23f074dfe53 100644 --- a/account_cost_center/views/account_move_line_views.xml +++ b/account_cost_center/views/account_move_line_views.xml @@ -4,7 +4,7 @@ account.move.line - + @@ -14,7 +14,7 @@ 1 - + diff --git a/account_cost_center/views/account_move_views.xml b/account_cost_center/views/account_move_views.xml index a668e797dfc..5602b85f980 100644 --- a/account_cost_center/views/account_move_views.xml +++ b/account_cost_center/views/account_move_views.xml @@ -19,6 +19,12 @@ + + { + "default_cost_center_id": cost_center_id, + } + +