diff --git a/account_analytic_no_lines/README.rst b/account_analytic_no_lines/README.rst new file mode 100644 index 0000000000..0cdf094b26 --- /dev/null +++ b/account_analytic_no_lines/README.rst @@ -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 +`_. 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 `_. + +Contributors +------------ + +* Thomas Binsfeld + +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. diff --git a/account_analytic_no_lines/__init__.py b/account_analytic_no_lines/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/account_analytic_no_lines/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_analytic_no_lines/__openerp__.py b/account_analytic_no_lines/__openerp__.py new file mode 100644 index 0000000000..189dc88fd0 --- /dev/null +++ b/account_analytic_no_lines/__openerp__.py @@ -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', + ], +} diff --git a/account_analytic_no_lines/data/data_account_analytic_group.xml b/account_analytic_no_lines/data/data_account_analytic_group.xml new file mode 100644 index 0000000000..bd32cb2531 --- /dev/null +++ b/account_analytic_no_lines/data/data_account_analytic_group.xml @@ -0,0 +1,11 @@ + + + + + + + Hide Analytic Entries + + + diff --git a/account_analytic_no_lines/models/__init__.py b/account_analytic_no_lines/models/__init__.py new file mode 100644 index 0000000000..ee8d75d238 --- /dev/null +++ b/account_analytic_no_lines/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_invoice +from . import account_move_line diff --git a/account_analytic_no_lines/models/account_invoice.py b/account_analytic_no_lines/models/account_invoice.py new file mode 100644 index 0000000000..9c02f41508 --- /dev/null +++ b/account_analytic_no_lines/models/account_invoice.py @@ -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 diff --git a/account_analytic_no_lines/models/account_move_line.py b/account_analytic_no_lines/models/account_move_line.py new file mode 100644 index 0000000000..f860a463f7 --- /dev/null +++ b/account_analytic_no_lines/models/account_move_line.py @@ -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 diff --git a/account_analytic_no_lines/static/description/icon.png b/account_analytic_no_lines/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/account_analytic_no_lines/static/description/icon.png differ diff --git a/account_analytic_no_lines/tests/__init__.py b/account_analytic_no_lines/tests/__init__.py new file mode 100644 index 0000000000..24b8200363 --- /dev/null +++ b/account_analytic_no_lines/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_analytic_no_lines diff --git a/account_analytic_no_lines/tests/test_account_analytic_no_lines.py b/account_analytic_no_lines/tests/test_account_analytic_no_lines.py new file mode 100644 index 0000000000..56bf7aebb3 --- /dev/null +++ b/account_analytic_no_lines/tests/test_account_analytic_no_lines.py @@ -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) diff --git a/account_analytic_no_lines/views/account_analytic.xml b/account_analytic_no_lines/views/account_analytic.xml new file mode 100644 index 0000000000..0723d58ba8 --- /dev/null +++ b/account_analytic_no_lines/views/account_analytic.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/account_analytic_no_lines/views/account_analytic_account.xml b/account_analytic_no_lines/views/account_analytic_account.xml new file mode 100644 index 0000000000..fbde921e1e --- /dev/null +++ b/account_analytic_no_lines/views/account_analytic_account.xml @@ -0,0 +1,35 @@ + + + + + + + account.analytic.account.form (in account_analytic_no_lines) + account.analytic.account + + + + account_analytic_no_lines.hide_analytic_entries + + + + + + account.analytic.account.tree (in account_analytic_no_lines) + account.analytic.account + + + + 1 + + + 1 + + + 1 + + + + + diff --git a/setup/account_analytic_no_lines/odoo_addons/__init__.py b/setup/account_analytic_no_lines/odoo_addons/__init__.py new file mode 100644 index 0000000000..de40ea7ca0 --- /dev/null +++ b/setup/account_analytic_no_lines/odoo_addons/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/account_analytic_no_lines/odoo_addons/account_analytic_no_lines b/setup/account_analytic_no_lines/odoo_addons/account_analytic_no_lines new file mode 120000 index 0000000000..116a55db4a --- /dev/null +++ b/setup/account_analytic_no_lines/odoo_addons/account_analytic_no_lines @@ -0,0 +1 @@ +../../../account_analytic_no_lines \ No newline at end of file diff --git a/setup/account_analytic_no_lines/setup.py b/setup/account_analytic_no_lines/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/account_analytic_no_lines/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)