forked from OCA/account-analytic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.0][ADD] account_analytic_no_lines (OCA#69)
[ADD] account_analytic_no_lines
- Loading branch information
1 parent
a53e5dd
commit 0847395
Showing
12 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
========================= | ||
Account Analytic No Lines | ||
========================= | ||
|
||
This module hides analytics lines from accounting menus and disable their generation from an invoice or a move line. | ||
|
||
In many situations (i.e. when there are no analytic distribution, and when people don't consider timesheets as analytic entries), | ||
the generation of analytic entries for each account move is redundant, creates overhead and poses a risk of desynchronization between analytic data and GL entries. | ||
In such situations users are happy to do their analytics reporting on account move lines and don't need analytic entries. | ||
This module disables the generation of analytic entries and related menus. | ||
|
||
Usage | ||
===== | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/87/9.0 | ||
|
||
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt | ||
.. branch is "8.0" for example | ||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/account_analytic/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. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Thomas Binsfeld <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Account Analytic No Lines', | ||
'summary': """ | ||
This module hides analytics lines from accounting menus and disable | ||
their generation from an invoice or a move line.""", | ||
'version': '9.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', | ||
'website': 'www.acsone.eu', | ||
'depends': [ | ||
'account', | ||
'analytic', | ||
], | ||
'data': [ | ||
'views/account_analytic_account.xml', | ||
'data/data_account_analytic_group.xml', | ||
'views/account_analytic.xml', | ||
], | ||
} |
11 changes: 11 additions & 0 deletions
11
account_analytic_no_lines/data/data_account_analytic_group.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2016 Acsone SA/NV | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<odoo> | ||
|
||
<record id="hide_analytic_entries" model="res.groups"> | ||
<field name="name">Hide Analytic Entries</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import account_invoice | ||
from . import account_move_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import api, models | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
|
||
_inherit = 'account.invoice' | ||
|
||
@api.multi | ||
def finalize_invoice_move_lines(self, move_lines): | ||
move_lines = super(AccountInvoice, self)\ | ||
.finalize_invoice_move_lines(move_lines) | ||
move_lines[0][2].pop('analytic_line_ids') | ||
return move_lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import api, models | ||
|
||
|
||
class AccountMoveLine(models.Model): | ||
|
||
_inherit = 'account.move.line' | ||
|
||
@api.multi | ||
def create_analytic_lines(self): | ||
pass |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_account_analytic_no_lines |
115 changes: 115 additions & 0 deletions
115
account_analytic_no_lines/tests/test_account_analytic_no_lines.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp.tests.common import SavepointCase | ||
|
||
|
||
class TestAccountAnalyticNoLines(SavepointCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
super(TestAccountAnalyticNoLines, cls).setUpClass() | ||
|
||
# ENVIRONMENTS | ||
|
||
cls.account_account = cls.env['account.account'] | ||
cls.account_analytic_line = cls.env['account.analytic.line'] | ||
cls.account_journal = cls.env['account.journal'] | ||
cls.account_move_line = cls.env['account.move.line'] | ||
cls.account_invoice = cls.env['account.invoice'] | ||
cls.account_invoice_line = cls.env['account.invoice.line'] | ||
|
||
# INSTANCES | ||
|
||
# Instance: user | ||
cls.user = cls.env.ref('base.res_partner_2') | ||
|
||
# Instance: accounts | ||
cls.account_440000 = cls.account_account.create({ | ||
'name': 'Entreprises liées', | ||
'code': '440000_demo', | ||
'user_type_id': | ||
cls.env.ref('account.data_account_type_payable').id, | ||
'reconcile': True}) | ||
cls.account_550001 = cls.account_account.create({ | ||
'name': 'Banque', | ||
'code': '550001_demo', | ||
'user_type_id': | ||
cls.env.ref('account.data_account_type_liquidity').id, | ||
'reconcile': False}) | ||
cls.account_600000 = cls.account_account.create({ | ||
'name': 'Achats de matières premières', | ||
'code': '600000_demo', | ||
'user_type_id': | ||
cls.env.ref('account.data_account_type_expenses').id, | ||
'reconcile': False}) | ||
|
||
# Journal | ||
cls.journal = cls.account_journal.create({ | ||
'name': 'Bank Journal Test', | ||
'type': 'bank', | ||
'code': 'BKTEST', | ||
'default_debit_account_id': cls.account_550001.id, | ||
'default_credit_account_id': cls.account_550001.id}) | ||
|
||
# Invoice lines | ||
cls.invoice_line_1 = cls.account_invoice_line.create({ | ||
'name': 'Test invoice line 1', | ||
'price_unit': 50, | ||
'quantity': 2, | ||
'account_id': cls.account_600000.id}) | ||
cls.invoice_line_2 = cls.account_invoice_line.create({ | ||
'name': 'Test invoice line 2', | ||
'price_unit': 25, | ||
'quantity': 2, | ||
'account_id': cls.account_600000.id}) | ||
cls.invoice_line_3 = cls.account_invoice_line.create({ | ||
'name': 'Test invoice line 3', | ||
'price_unit': 100, | ||
'quantity': 1, | ||
'account_id': cls.account_600000.id}) | ||
|
||
# Invoice | ||
cls.invoice = cls.account_invoice.create({ | ||
'partner_id': cls.user.id, | ||
'account_id': cls.account_440000.id, | ||
'type': 'in_invoice', | ||
'invoice_line_ids': [(6, 0, [cls.invoice_line_1.id, | ||
cls.invoice_line_2.id, | ||
cls.invoice_line_3.id])]}) | ||
cls.invoice.action_move_create() | ||
|
||
def test_create_analytic_lines(self): | ||
""" | ||
Test the expected result when the method ´create_analytic_lines` is | ||
called on an invoice. | ||
The expected result is that no analytic line has been created | ||
for this invoice. | ||
""" | ||
move_lines = self.account_move_line.search([ | ||
('invoice_id', '=', self.invoice.id)]) | ||
for line in move_lines: | ||
line.create_analytic_lines() | ||
|
||
analytic_lines =\ | ||
self.account_analytic_line.search([ | ||
('move_id', 'in', move_lines.ids)]).ids | ||
self.assertFalse(analytic_lines) | ||
|
||
def test_finalize_invoice_move_lines(self): | ||
""" | ||
Test the expected result when the method ´finalize_invoice_move_lines` | ||
is called on an invoice. | ||
The expected result is that no analytic line has been created | ||
for this invoice. | ||
""" | ||
move_lines = self.account_move_line.search([('invoice_id', | ||
'=', | ||
self.invoice.id)]) | ||
self.invoice.action_move_create() | ||
analytic_lines =\ | ||
self.account_analytic_line.search([('move_id', | ||
'in', | ||
move_lines.ids)]).ids | ||
self.assertFalse(analytic_lines) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2016 Acsone SA/NV | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<odoo> | ||
|
||
<record model="ir.ui.menu" id="account.menu_action_analytic_lines_tree"> | ||
<field name="groups_id" eval="[(6,0,[ref('account_analytic_no_lines.hide_analytic_entries')])]"/> | ||
</record> | ||
|
||
<record model="ir.ui.menu" id="account.menu_action_analytic_account_tree2"> | ||
<field name="groups_id" eval="[(6,0,[ref('account_analytic_no_lines.hide_analytic_entries')])]"/> | ||
</record> | ||
|
||
</odoo> |
35 changes: 35 additions & 0 deletions
35
account_analytic_no_lines/views/account_analytic_account.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2016 ACSONE SA/NV | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<odoo> | ||
|
||
<record model="ir.ui.view" id="account_analytic_account_form_view"> | ||
<field name="name">account.analytic.account.form (in account_analytic_no_lines)</field> | ||
<field name="model">account.analytic.account</field> | ||
<field name="inherit_id" ref="analytic.view_account_analytic_account_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div[@name='button_box']/button[@name=%(analytic.account_analytic_line_action)d]" position="attributes"> | ||
<attribute name="groups">account_analytic_no_lines.hide_analytic_entries</attribute> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="account_analytic_account_tree_view"> | ||
<field name="name">account.analytic.account.tree (in account_analytic_no_lines)</field> | ||
<field name="model">account.analytic.account</field> | ||
<field name="inherit_id" ref="analytic.view_account_analytic_account_list"/> | ||
<field name="arch" type="xml"> | ||
<field name="debit" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
<field name="credit" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
<field name="balance" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |