From 5f40be08de256ad5aaf1e6c66acf0ae5b5730987 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 13 Aug 2015 01:28:26 +0200 Subject: [PATCH 01/18] [ADD] analytic_partner Classify analytic items by partner ================================== This module adds a partner on each analytic item for allowing to have another dimension for analysing data. It also handles the proper propagation of this field to the created analytic entries when validating invoices. Configuration ============= You have to be granted as at least "Accountant" in your user profile and have checked the "Analytic Accounting" access right. Usage ===== Go to Accounting > Analytic Journal Items, and there, you can set the partner for the analytic items, and search or group by it. You can also go to a partner, and click on the smart-button "Cost/Revenue", placed on the upper-right part, and you will navigate to the analytic items associated to this partner. Known issues / Roadmap ====================== * This module hasn't been tested with *account_analytic_plans* module installed, so maybe it's incompatible with it. --- analytic_partner/README.rst | 58 +++++ analytic_partner/__init__.py | 4 + analytic_partner/__openerp__.py | 23 ++ analytic_partner/i18n/analytic_partner.pot | 33 +++ analytic_partner/i18n/es.po | 33 +++ analytic_partner/models/__init__.py | 6 + .../models/account_analytic_line.py | 12 + analytic_partner/models/account_invoice.py | 18 ++ analytic_partner/models/account_move_line.py | 15 ++ analytic_partner/static/description/icon.png | Bin 0 -> 7521 bytes analytic_partner/static/description/icon.svg | 229 ++++++++++++++++++ analytic_partner/tests/__init__.py | 4 + .../tests/test_analytic_partner.py | 38 +++ .../views/account_analytic_line_views.xml | 39 +++ analytic_partner/views/res_partner_views.xml | 30 +++ 15 files changed, 542 insertions(+) create mode 100644 analytic_partner/README.rst create mode 100644 analytic_partner/__init__.py create mode 100644 analytic_partner/__openerp__.py create mode 100644 analytic_partner/i18n/analytic_partner.pot create mode 100644 analytic_partner/i18n/es.po create mode 100644 analytic_partner/models/__init__.py create mode 100644 analytic_partner/models/account_analytic_line.py create mode 100644 analytic_partner/models/account_invoice.py create mode 100644 analytic_partner/models/account_move_line.py create mode 100644 analytic_partner/static/description/icon.png create mode 100644 analytic_partner/static/description/icon.svg create mode 100644 analytic_partner/tests/__init__.py create mode 100644 analytic_partner/tests/test_analytic_partner.py create mode 100644 analytic_partner/views/account_analytic_line_views.xml create mode 100644 analytic_partner/views/res_partner_views.xml diff --git a/analytic_partner/README.rst b/analytic_partner/README.rst new file mode 100644 index 0000000000..a4db3e9bc3 --- /dev/null +++ b/analytic_partner/README.rst @@ -0,0 +1,58 @@ +Classify analytic items by partner +================================== + +This module adds a partner on each analytic item for allowing to have another +dimension for analysing data. + +It also handles the proper propagation of this field to the created analytic +entries when validating invoices. + +Configuration +============= + +You have to be granted as at least "Accountant" in your user profile and +have checked the "Analytic Accounting" access right. + +Usage +===== + +Go to Accounting > Analytic Journal Items, and there, you can set the partner +for the analytic items, and search or group by it. + +You can also go to a partner, and click on the smart-button "Cost/Revenue", +placed on the upper-right part, and you will navigate to the analytic items +associated to this partner. + + +.. 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/8.0 + +Known issues / Roadmap +====================== + +* This module hasn't been tested with *account_analytic_plans* module +installed, so maybe it's incompatible with it. + +Credits +======= + +Contributors +------------ + +* Pedro M. Baeza + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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 http://odoo-community.org. diff --git a/analytic_partner/__init__.py b/analytic_partner/__init__.py new file mode 100644 index 0000000000..ab6f30b1a1 --- /dev/null +++ b/analytic_partner/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from . import models diff --git a/analytic_partner/__openerp__.py b/analytic_partner/__openerp__.py new file mode 100644 index 0000000000..4436e11c51 --- /dev/null +++ b/analytic_partner/__openerp__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + 'name': 'Partner in analytics', + 'version': '8.0.1.0.0', + 'summary': 'Classify analytic entries by partner', + 'category': 'Analytic Accounting', + 'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza, ' + 'Antiun Ingeniería S.L., ' + 'Odoo Community Association (OCA)', + 'website': 'http://www.serviciosbaeza.com', + 'depends': [ + 'analytic', + 'account', + ], + 'data': [ + 'views/account_analytic_line_views.xml', + 'views/res_partner_views.xml', + ], + "installable": True, +} diff --git a/analytic_partner/i18n/analytic_partner.pot b/analytic_partner/i18n/analytic_partner.pot new file mode 100644 index 0000000000..14e41a48e3 --- /dev/null +++ b/analytic_partner/i18n/analytic_partner.pot @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * analytic_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-08-12 23:41+0000\n" +"PO-Revision-Date: 2015-08-12 23:41+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: analytic_partner +#: view:res.partner:analytic_partner.view_partner_form_analytic +msgid "Cost/Revenue" +msgstr "" + +#. module: analytic_partner +#: model:ir.actions.act_window,name:analytic_partner.act_analytic_cost_revenue +msgid "Costs & Revenues" +msgstr "" + +#. module: analytic_partner +#: view:account.analytic.line:analytic_partner.view_account_analytic_line_filter_partner +#: field:account.analytic.line,partner_id:0 +msgid "Partner" +msgstr "" + diff --git a/analytic_partner/i18n/es.po b/analytic_partner/i18n/es.po new file mode 100644 index 0000000000..69a7fe6b7c --- /dev/null +++ b/analytic_partner/i18n/es.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * analytic_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-08-12 23:41+0000\n" +"PO-Revision-Date: 2015-08-12 23:41+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: analytic_partner +#: view:res.partner:analytic_partner.view_partner_form_analytic +msgid "Cost/Revenue" +msgstr "Costes/Ingresos" + +#. module: analytic_partner +#: model:ir.actions.act_window,name:analytic_partner.act_analytic_cost_revenue +msgid "Costs & Revenues" +msgstr "Costes e ingresos" + +#. module: analytic_partner +#: view:account.analytic.line:analytic_partner.view_account_analytic_line_filter_partner +#: field:account.analytic.line,partner_id:0 +msgid "Partner" +msgstr "Empresa" + diff --git a/analytic_partner/models/__init__.py b/analytic_partner/models/__init__.py new file mode 100644 index 0000000000..91f9a2503c --- /dev/null +++ b/analytic_partner/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from . import account_analytic_line +from . import account_invoice +from . import account_move_line diff --git a/analytic_partner/models/account_analytic_line.py b/analytic_partner/models/account_analytic_line.py new file mode 100644 index 0000000000..8ace711d70 --- /dev/null +++ b/analytic_partner/models/account_analytic_line.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from openerp import models, fields + + +class AccountAnalyticLine(models.Model): + _inherit = 'account.analytic.line' + + partner_id = fields.Many2one( + comodel_name='res.partner', string="Partner", + domain="[('parent_id', '=', False)]") diff --git a/analytic_partner/models/account_invoice.py b/analytic_partner/models/account_invoice.py new file mode 100644 index 0000000000..9ea89ed0c8 --- /dev/null +++ b/analytic_partner/models/account_invoice.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from openerp import models, api + + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + @api.multi + def _get_analytic_lines(self): + """Put partner on generated analytic lines""" + iml = super(AccountInvoice, self)._get_analytic_lines() + for il in iml: + for analytic_vals in il.get('analytic_lines', []): + analytic_vals[2]['partner_id'] = ( + self.partner_id.commercial_partner_id.id) + return iml diff --git a/analytic_partner/models/account_move_line.py b/analytic_partner/models/account_move_line.py new file mode 100644 index 0000000000..64a401cbef --- /dev/null +++ b/analytic_partner/models/account_move_line.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from openerp import models, api + + +class AccountMoveLine(models.Model): + _inherit = 'account.move.line' + + @api.model + def _prepare_analytic_line(self, obj_line): + res = super(AccountMoveLine, self)._prepare_analytic_line(obj_line) + res['partner_id'] = ( + obj_line.invoice.partner_id.commercial_partner_id.id) + return res diff --git a/analytic_partner/static/description/icon.png b/analytic_partner/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..faaea09c7ae3b2d38bf91997f74bc99d3abdc832 GIT binary patch literal 7521 zcmZ`;cRX9)`%ml$WYe;-$(t|$Vl+_E_J5? zd`IN3ZS;f;e}$2`Cg9)6VTLyTc=@US8cla!M3d7DX`^R|zwx%tj35N(5P!va*%cr^ZP1;lZ{0FRhspw~uY!BX&Dp(B zwO%ex1C!%#H)h7uLMuFPzkHnwEXk0!2poPoRQIF2Un>8F+1 zXD8uKIvnxsGMc4!9R%ls%RMN{s3Wd;RkAQDc9BcJ2Fs8ieMfQDBx*8Ip<@oDKiHev z9g@H#Bd;$?{ zn@qBSTGJ9f`E^PeB?Yje4%2f_Rf%?}oHS0WJk_40H`^w~ubM-+w7Msxj*6yf*y)aRRb66NFdwH0YGlsT|FeT zxD_+T0Mt9AL2=EHOS}<9i}VZTy;<b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}PFuN&-~C_v9b(4xZz6I`1tITowm z9qp~sF^-nU4OaazGUNAOEp)y4Hb7$`WE=19%HyFgqx`mTOLwR3IA!Bm33#Y*97NN1 zxx$S + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/analytic_partner/tests/__init__.py b/analytic_partner/tests/__init__.py new file mode 100644 index 0000000000..508624f342 --- /dev/null +++ b/analytic_partner/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from . import test_analytic_partner diff --git a/analytic_partner/tests/test_analytic_partner.py b/analytic_partner/tests/test_analytic_partner.py new file mode 100644 index 0000000000..dfebf6c027 --- /dev/null +++ b/analytic_partner/tests/test_analytic_partner.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +import openerp.tests.common as common +from openerp import workflow + + +class TestAnalyticPartner(common.TransactionCase): + + def setUp(self): + super(TestAnalyticPartner, self).setUp() + product = self.env.ref('product.product_product_5') + self.analytic_account = self.env['account.analytic.account'].create( + {'name': 'Test Analytic Account', + 'state': 'draft', + 'type': 'normal'} + ) + self.invoice = self.env['account.invoice'].create( + {'journal_id': self.env.ref('account.sales_journal').id, + 'partner_id': self.env.ref('base.res_partner_3').id, + 'account_id': self.env.ref('account.a_recv').id, + 'invoice_line': [ + (0, 0, {'product_id': product.id, + 'name': 'Test', + 'account_analytic_id': self.analytic_account.id, + 'quantity': 10.0, + })], + }) + workflow.trg_validate(self.uid, 'account.invoice', self.invoice.id, + 'invoice_open', self.cr) + + def test_partner_from_invoice(self): + analytic_lines = self.invoice.move_id.mapped('line_id.analytic_lines') + for analytic_line in analytic_lines: + self.assertEqual( + analytic_line.partner_id, + self.invoice.partner_id.commercial_partner_id, + 'Invoice partner has not been propagated to the analytic line') diff --git a/analytic_partner/views/account_analytic_line_views.xml b/analytic_partner/views/account_analytic_line_views.xml new file mode 100644 index 0000000000..c088e790a7 --- /dev/null +++ b/analytic_partner/views/account_analytic_line_views.xml @@ -0,0 +1,39 @@ + + + + + + Analytic entries tree (with partner) + account.analytic.line + + + + + + + + + + Analytic entries form (with partner) + account.analytic.line + + + + + + + + + + Analytic entries search (with partner) + account.analytic.line + + + + + + + + + + diff --git a/analytic_partner/views/res_partner_views.xml b/analytic_partner/views/res_partner_views.xml new file mode 100644 index 0000000000..0fe782eba8 --- /dev/null +++ b/analytic_partner/views/res_partner_views.xml @@ -0,0 +1,30 @@ + + + + + + {'search_default_group_date': 1, 'search_default_group_journal': 1, 'default_partner_id': active_id} + [('partner_id', 'child_of', active_id)] + Costs & Revenues + account.analytic.line + res.partner + tree,form + form + + + + res.partner.form.analytic + res.partner + + + +