Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG][10.0] account_analytic_distribution module
- Loading branch information
Showing
19 changed files
with
746 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,99 @@ | ||
.. 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 Distribution | ||
============================= | ||
|
||
Analytic accounting helps you to analyze costs and revenues in your company. | ||
Analytic analysis allows you to answer specific business questions and | ||
forecast possible future financial scenarios. | ||
|
||
In Odoo, analytic accounts are linked to general accounts but are treated | ||
totally independently. So, you can enter various different analytic operations | ||
that have no counterpart in the general financial accounts. | ||
|
||
By default, you can enter only one analytic account for each journal item and | ||
only one analytic line it will be created. | ||
|
||
With this module, you can define an analytic distribution in every journal | ||
item, so you can distribute total amount to several analytic accounts. | ||
|
||
|
||
Configuration | ||
============= | ||
|
||
To configure your analytic distributions go to: | ||
|
||
#. *Invoicing > Configuration > Settings* and activate checkbox **Analytic | ||
accounting** in *Accounting & Finance*. | ||
#. Now you see the menu *Invoicing > Configuration > Analytic Accounting > | ||
Analytic Distributions* | ||
#. Create a new analytic distribution and enter its name | ||
#. Add some distribution rules: you must specify the analytic account and | ||
percentage of total move line amount you want to distribute. | ||
#. Save distribution. | ||
#. You can set if sum of total percent of analytic accounts must be 100% or | ||
not, if yo go to *Invoicing > Configuration > Settings* and set checkbox | ||
**Force percent** in *Accounting & Finance*. | ||
|
||
|
||
Usage | ||
===== | ||
|
||
After installation, you'll see a new 'Analytic Distribution' column in | ||
Journal Entry form (in Journal Items tab), in order to select the | ||
analytic distribution you want when creating journal entries manually. You | ||
can do the same in account invoice form and select your analytic distribution | ||
in invoice lines. | ||
|
||
Multiple analytic lines are created when the invoice or the entries are | ||
confirmed. | ||
|
||
You can continue using 'Analityc Account' field, but 'Analytic Distribution' | ||
has precedence if defined. | ||
|
||
|
||
.. 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/10.0 | ||
|
||
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 | ||
------------ | ||
|
||
* Pedro M. Baeza <pedro.baeza@tecnativa.com> | ||
* Rafael Blasco <rafael.blasco@tecnativa.com> | ||
* Antonio Espinosa <antonio.espinosa@tecnativa.com> | ||
* Vicent Cubells <antonio.espinosa@tecnativa.com> | ||
|
||
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,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
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,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# Copyright 2017 Vicent Cubells - <vicent.cubells@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Account Analytic Distribution", | ||
"summary": "Distribute incoming/outcoming account moves to several " | ||
"analytic accounts", | ||
"version": "10.0.1.0.0", | ||
"category": "Accounting & Finance", | ||
"website": "https://www.tecnativa.com", | ||
"author": "Tecnativa, " | ||
"Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"account", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/res_config_view.xml", | ||
"views/account_analytic_distribution_view.xml", | ||
"views/account_move_view.xml", | ||
"views/account_invoice_view.xml", | ||
"views/account_move_line_view.xml", | ||
], | ||
"installable": True, | ||
"application": False, | ||
} |
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,139 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_analytic_distribution | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 9.0c\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-04-26 17:23+0000\n" | ||
"PO-Revision-Date: 2017-04-26 17:23+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: account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_analytic_distribution_rule_analytic_account_id | ||
msgid "Analytic account" | ||
msgstr "Cuenta analítica" | ||
|
||
#. module: account_analytic_distribution | ||
#: sql_constraint:account.analytic.distribution.rule:0 | ||
#: code:addons/account_analytic_distribution/models/account_analytic_distribution_rule.py:38 | ||
#, python-format | ||
msgid "Analytic account must be unique per distribution!" | ||
msgstr "La cuenta analítica debe ser única por distribución!" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model,name:account_analytic_distribution.model_account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_invoice_line_analytic_distribution_id | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_move_line_analytic_distribution_id | ||
#: model:ir.ui.view,arch_db:account_analytic_distribution.account_analytic_distribution_form | ||
#: model:ir.ui.view,arch_db:account_analytic_distribution.account_analytic_distribution_search | ||
msgid "Analytic distribution" | ||
msgstr "Distribución analítica" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model,name:account_analytic_distribution.model_account_analytic_distribution_rule | ||
msgid "Analytic distribution rule" | ||
msgstr "Regla de distribución analítica" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.actions.act_window,name:account_analytic_distribution.account_analytic_distribution_action | ||
#: model:ir.ui.menu,name:account_analytic_distribution.menu_account_analytic_distribution | ||
#: model:ir.ui.view,arch_db:account_analytic_distribution.account_analytic_distribution_search | ||
#: model:ir.ui.view,arch_db:account_analytic_distribution.account_analytic_distribution_tree | ||
msgid "Analytic distributions" | ||
msgstr "Distribuciones analíticas" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_analytic_distribution_company_id | ||
msgid "Company" | ||
msgstr "Compañía" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_analytic_distribution_rule_distribution_id | ||
msgid "Distribution" | ||
msgstr "Distribución" | ||
|
||
#. module: account_analytic_distribution | ||
#: sql_constraint:account.analytic.distribution:0 | ||
#: code:addons/account_analytic_distribution/models/account_analytic_distribution.py:35 | ||
#, python-format | ||
msgid "Distribution name must be unique per Company!" | ||
msgstr "El nombre de la distribución ha de ser único por compañía!" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_analytic_distribution_rule_ids | ||
#: model:ir.ui.view,arch_db:account_analytic_distribution.account_analytic_distribution_form | ||
msgid "Distribution rules" | ||
msgstr "Reglas de distribución" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_res_company_force_percent | ||
msgid "Force percent" | ||
msgstr "Forzar el porcentaje" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model.fields,help:account_analytic_distribution.field_res_company_force_percent | ||
msgid "If checked, the sum of all percents of the analytic accounts in a distribution of this company must be 100%." | ||
msgstr "Si está marcado, la suma del porcentaje de todas las cuentas analíticas de una distribución de esta compañía debe ser 100%." | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model,name:account_analytic_distribution.model_account_invoice | ||
msgid "Invoice" | ||
msgstr "Factura" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model,name:account_analytic_distribution.model_account_invoice_line | ||
msgid "Invoice Line" | ||
msgstr "Linea de factura" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model,name:account_analytic_distribution.model_account_move_line | ||
msgid "Journal Item" | ||
msgstr "Apunte contable" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_analytic_distribution_name | ||
msgid "Name" | ||
msgstr "Nombre" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_analytic_distribution_rule_percent | ||
msgid "Percentage" | ||
msgstr "Porcentaje" | ||
|
||
#. module: account_analytic_distribution | ||
#: sql_constraint:account.analytic.distribution.rule:0 | ||
#: code:addons/account_analytic_distribution/models/account_analytic_distribution_rule.py:34 | ||
#, python-format | ||
msgid "Percentage must be positive!" | ||
msgstr "El porcentaje ha de ser positivo!" | ||
|
||
#. module: account_analytic_distribution | ||
#: sql_constraint:account.analytic.distribution.rule:0 | ||
#: code:addons/account_analytic_distribution/models/account_analytic_distribution_rule.py:36 | ||
#, python-format | ||
msgid "Percentage must less or equal 100%!" | ||
msgstr "El porcentaje ha de ser menor o iguak a 100%!" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.ui.view,arch_db:account_analytic_distribution.account_analytic_distribution_form | ||
msgid "Rules" | ||
msgstr "Reglas" | ||
|
||
#. module: account_analytic_distribution | ||
#: code:addons/account_analytic_distribution/models/account_analytic_distribution.py:49 | ||
#, python-format | ||
msgid "Rules percent doesn't sum 100%" | ||
msgstr "El porcentaje de las reglas no suman 100%" | ||
|
||
#. module: account_analytic_distribution | ||
#: model:ir.model.fields,field_description:account_analytic_distribution.field_account_analytic_distribution_rule_sequence | ||
msgid "Sequence" | ||
msgstr "Secuencia" | ||
|
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,9 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import account_analytic_distribution | ||
from . import account_move_line | ||
from . import account_invoice | ||
from . import account_invoice_line | ||
from . import res_config |
86 changes: 86 additions & 0 deletions
86
account_analytic_distribution/models/account_analytic_distribution.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,86 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# Copyright 2017 Vicent Cubells - <vicent.cubells@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class AccountAnalyticDistribution(models.Model): | ||
_name = "account.analytic.distribution" | ||
_description = "Analytic distribution" | ||
_order = "name asc" | ||
|
||
@api.model | ||
def _get_default_company(self): | ||
m_company = self.env['res.company'] | ||
return m_company._company_default_get('account.analytic.distribution') | ||
|
||
name = fields.Char( | ||
string='Name', | ||
required=True, | ||
) | ||
company_id = fields.Many2one( | ||
comodel_name='res.company', | ||
string='Company', | ||
required=True, | ||
default=_get_default_company, | ||
) | ||
rule_ids = fields.One2many( | ||
string="Distribution rules", | ||
comodel_name='account.analytic.distribution.rule', | ||
inverse_name='distribution_id', | ||
) | ||
|
||
_sql_constraints = [ | ||
('name_uniq', 'unique(name, company_id)', | ||
_('Distribution name must be unique per Company!')), | ||
] | ||
|
||
@api.multi | ||
@api.constrains('rule_ids') | ||
def _check_rule_ids(self): | ||
for distribution in self: | ||
force_percent = self.env['ir.values'].get_default( | ||
'account.config.settings', | ||
'group_force_percent', | ||
) | ||
if not force_percent: | ||
continue | ||
total = sum(distribution.rule_ids.mapped('percent')) | ||
if total != 100.00: | ||
raise ValidationError(_("Rules percent doesn't sum 100%")) | ||
|
||
|
||
class AccountAnalyticDistributionRule(models.Model): | ||
_name = "account.analytic.distribution.rule" | ||
_description = "Analytic distribution rule" | ||
_order = "sequence asc" | ||
|
||
sequence = fields.Integer( | ||
string='Sequence', | ||
default=10, | ||
) | ||
distribution_id = fields.Many2one( | ||
string="Distribution", | ||
required=True, | ||
comodel_name='account.analytic.distribution', | ||
) | ||
percent = fields.Float( | ||
string="Percentage", | ||
required=True, | ||
) | ||
analytic_account_id = fields.Many2one( | ||
string="Analytic account", | ||
comodel_name='account.analytic.account', | ||
) | ||
|
||
_sql_constraints = [ | ||
('percent_positive', 'CHECK(percent > 0)', | ||
_('Percentage must be positive!')), | ||
('percent_limit', 'CHECK(percent <= 100)', | ||
_('Percentage must less or equal 100%!')), | ||
('analytic_uniq', 'unique(distribution_id, analytic_account_id)', | ||
_('Analytic account must be unique per distribution!')), | ||
] |
Oops, something went wrong.