Skip to content

Commit

Permalink
[MIG] account_cost_center: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Jan 15, 2025
1 parent 9168aff commit 3d3debd
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 34 deletions.
17 changes: 9 additions & 8 deletions account_cost_center/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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

Expand All @@ -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

Expand All @@ -74,7 +74,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/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 <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_cost_center%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_cost_center%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand All @@ -93,6 +93,7 @@ Contributors
* Richard Dijkstra <[email protected]>
* Andrea Stirpe <[email protected]>
* Antonio Esposito <[email protected]>
* `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_

Maintainers
~~~~~~~~~~~
Expand All @@ -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 <https://github.com/OCA/account-financial-tools/tree/15.0/account_cost_center>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/account_cost_center>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions account_cost_center/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions account_cost_center/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
* Richard Dijkstra <[email protected]>
* Andrea Stirpe <[email protected]>
* Antonio Esposito <[email protected]>
* `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_
25 changes: 14 additions & 11 deletions account_cost_center/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
: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.
Expand Down Expand Up @@ -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 }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Costcenter</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:697dce33e30296fb060a0f9fcb8be9b8807b5ba5c0d964de201ba90b34e53d24
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_cost_center"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_cost_center"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/16.0/account_cost_center"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_cost_center"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows the user to link every invoice line to a cost center
providing an extra dimension for the analysis.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -394,27 +394,27 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<blockquote>
<strong>Configuration &gt; Analytics accounting &gt; Cost centers</strong></blockquote>
<div class="figure align-center">
<img alt="Cost centers can be configured" src="https://raw.githubusercontent.com/OCA/account-financial-tools/15.0/account_cost_center/static/description/account_costcenter_1.png" />
<img alt="Cost centers can be configured" src="https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_cost_center/static/description/account_costcenter_1.png" />
</div>
<p>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.</p>
<div class="figure align-center">
<img alt="Cost centers can be selected on invoice lines" src="https://raw.githubusercontent.com/OCA/account-financial-tools/15.0/account_cost_center/static/description/account_costcenter_2.png" />
<img alt="Cost centers can be selected on invoice lines" src="https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_cost_center/static/description/account_costcenter_2.png" />
</div>
<p>This module adds the cost center concept to the reporting.</p>
<blockquote>
<strong>Accounting &gt; Invoice Analysis</strong></blockquote>
<p>Here you can select or unselect the cost center within your analysis.</p>
<div class="figure align-center">
<img alt="Cost centers can be selected on invoice lines" src="https://raw.githubusercontent.com/OCA/account-financial-tools/15.0/account_cost_center/static/description/account_costcenter_3.png" />
<img alt="Cost centers can be selected on invoice lines" src="https://raw.githubusercontent.com/OCA/account-financial-tools/16.0/account_cost_center/static/description/account_costcenter_3.png" />
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_cost_center%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_cost_center%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -432,16 +432,19 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Richard Dijkstra &lt;<a class="reference external" href="mailto:r.dijkstra&#64;onestein.nl">r.dijkstra&#64;onestein.nl</a>&gt;</li>
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
<li>Antonio Esposito &lt;<a class="reference external" href="mailto:a.esposito&#64;onestein.nl">a.esposito&#64;onestein.nl</a>&gt;</li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_cost_center">OCA/account-financial-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/16.0/account_cost_center">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
60 changes: 49 additions & 11 deletions account_cost_center/tests/test_cost_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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)
4 changes: 2 additions & 2 deletions account_cost_center/views/account_move_line_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_form" />
<field name="arch" type="xml">
<field name="analytic_account_id" position="after">
<field name="analytic_distribution" position="after">
<field name="cost_center_id" />
</field>
</field>
Expand All @@ -14,7 +14,7 @@
<field name="inherit_id" ref="account.view_move_line_tree" />
<field name="priority">1</field>
<field name="arch" type="xml">
<field name="analytic_account_id" position="after">
<field name="analytic_distribution" position="after">
<field name="cost_center_id" />
</field>
</field>
Expand Down
6 changes: 6 additions & 0 deletions account_cost_center/views/account_move_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<field name="ref" position="after">
<field name="cost_center_id" />
</field>
<field name="invoice_line_ids" position="attributes">
<attribute name="context" operation="update">{
"default_cost_center_id": cost_center_id,
}</attribute>
</field>
</field>

</record>
</odoo>

0 comments on commit 3d3debd

Please sign in to comment.