-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.0][ADD] New module account_budget_distribution #23
Open
pedroguirao
wants to merge
6
commits into
OCA:11.0
Choose a base branch
from
pedroguirao:11.0-imp-account_budget_distribution
base: 11.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fcce71e
[ADD] New module account_budget_distribution
oihane f91edb7
[IMP] account_budget_distribution: wizard for distribution
oihane 06cf54f
[IMP] account_budget_distribution: added tests and translations
oihane 3e26f6c
[IMP] account_budget_distribution: only access wizard from button
oihane 27511d8
[IMP] account_budget_distribution: add new translation (#723)
oihane 83e5d35
Author ADD OCA
antoniocanovas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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 @@ | ||
.. 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 Budget Distribution | ||
=========================== | ||
|
||
With this module you can distribute symetrically an amount from a budget to its | ||
lines, taking into account its budget positions. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble, | ||
please check there if your issue has already been reported. If you spotted | ||
it first, help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es> | ||
* Ana Juaristi <anajuaristi@avanzosc.es> |
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,6 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import models | ||
from . import reports | ||
from . import wizards |
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,21 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
{ | ||
"name": "Account Budget Distribution", | ||
"version": "11.0.1.0.0", | ||
"category": "Accounting", | ||
"license": "AGPL-3", | ||
"author": "AvanzOSC","OCA" | ||
"website": "http://www.avanzosc.es", | ||
"depends": [ | ||
"account_budget", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"reports/crossovered_budget_resume_view.xml", | ||
"wizards/crossovered_budget_distribution_view.xml", | ||
"views/crossovered_budget_view.xml", | ||
], | ||
"installable": True, | ||
} |
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,142 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_budget_distribution | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-05-06 12:26+0000\n" | ||
"PO-Revision-Date: 2019-05-06 12:26+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_budget_distribution | ||
#: model:ir.model,name:account_budget_distribution.model_crossovered_budget | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_budget_id | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_summary_crossovered_budget_id | ||
#: model:ir.ui.view,arch_db:account_budget_distribution.crossovered_budget_summary_view_search | ||
msgid "Budget" | ||
msgstr "Presupuesto" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model,name:account_budget_distribution.model_crossovered_budget_distribution_line | ||
msgid "Budget Distribution Line" | ||
msgstr "Línea de distribución" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model,name:account_budget_distribution.model_crossovered_budget_distribution | ||
msgid "Budget Distribution Wizard" | ||
msgstr "Asistente de distribución" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_budget_post_id | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_summary_general_budget_id | ||
#: model:ir.ui.view,arch_db:account_budget_distribution.crossovered_budget_summary_view_search | ||
msgid "Budget Position" | ||
msgstr "Posición presupuestaria" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.ui.view,arch_db:account_budget_distribution.crossovered_budget_distribution_view_form | ||
msgid "Cancel" | ||
msgstr "Cancelar" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_create_uid | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_create_uid | ||
msgid "Created by" | ||
msgstr "Creado por" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_create_date | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_create_date | ||
msgid "Created on" | ||
msgstr "Creado en" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.actions.act_window,name:account_budget_distribution.action_crossovered_budget_summary_view | ||
#: model:ir.model,name:account_budget_distribution.model_crossovered_budget_summary | ||
#: model:ir.ui.menu,name:account_budget_distribution.crossovered_budget_summary_option_view | ||
msgid "Crossovered Budget Summary Lines" | ||
msgstr "Resumen de presupuestos" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_display_name | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_display_name | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_summary_display_name | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.ui.view,arch_db:account_budget_distribution.crossovered_budget_distribution_view_form | ||
msgid "Distribute" | ||
msgstr "Distribuir" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.actions.act_window,name:account_budget_distribution.action_crossovered_budget_distribution | ||
#: model:ir.ui.view,arch_db:account_budget_distribution.crossovered_budget_view_form | ||
msgid "Distribute Budget" | ||
msgstr "Distribuir otros costes" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_id | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_id | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_summary_id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution___last_update | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line___last_update | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_summary___last_update | ||
msgid "Last Modified on" | ||
msgstr "Última modificación en" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_write_uid | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_write_uid | ||
msgid "Last Updated by" | ||
msgstr "Última actualización de" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_write_date | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_write_date | ||
msgid "Last Updated on" | ||
msgstr "Última Actualización el" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_planned_amount | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_summary_planned_amount | ||
msgid "Planned Amount" | ||
msgstr "Previsión" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_ids | ||
#: model:ir.ui.view,arch_db:account_budget_distribution.crossovered_budget_view_form | ||
msgid "Summary" | ||
msgstr "Resumen" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_summary_ids | ||
msgid "Summary Lines" | ||
msgstr "Líneas de presupuesto" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.ui.view,arch_db:account_budget_distribution.crossovered_budget_summary_view_tree | ||
msgid "Total Planned Amount" | ||
msgstr "Total previsto" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.model.fields,field_description:account_budget_distribution.field_crossovered_budget_distribution_line_distribution_id | ||
msgid "Wizard" | ||
msgstr "Asistente" | ||
|
||
#. module: account_budget_distribution | ||
#: model:ir.ui.view,arch_db:account_budget_distribution.crossovered_budget_distribution_view_form | ||
msgid "or" | ||
msgstr "o" | ||
|
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,4 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import crossovered_budget |
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,12 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class CrossoveredBudget(models.Model): | ||
_inherit = 'crossovered.budget' | ||
|
||
summary_ids = fields.One2many( | ||
comodel_name='crossovered.budget.summary', | ||
inverse_name='crossovered_budget_id', string='Summary 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,4 @@ | ||
# Copyright 2018 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import crossovered_budget_resume |
36 changes: 36 additions & 0 deletions
36
account_budget_distribution/reports/crossovered_budget_resume.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,36 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import tools | ||
from odoo import api, fields, models | ||
|
||
|
||
class CrossoveredBudgetSummary(models.Model): | ||
_name = 'crossovered.budget.summary' | ||
_description = 'Crossovered Budget Summary Lines' | ||
_auto = False | ||
_rec_name = 'crossovered_budget_id' | ||
|
||
crossovered_budget_id = fields.Many2one( | ||
comodel_name='crossovered.budget', string='Budget') | ||
general_budget_id = fields.Many2one( | ||
comodel_name='account.budget.post', string='Budget Position') | ||
planned_amount = fields.Float(string='Planned Amount') | ||
|
||
@api.model_cr | ||
def init(self): | ||
tools.drop_view_if_exists(self.env.cr, self._table) | ||
self.env.cr.execute(""" | ||
CREATE or REPLACE VIEW %s as ( | ||
SELECT | ||
row_number() OVER () AS id, | ||
crossovered_budget_id, | ||
general_budget_id, | ||
SUM(planned_amount) as planned_amount | ||
FROM | ||
crossovered_budget_lines | ||
GROUP BY | ||
crossovered_budget_id, | ||
general_budget_id | ||
)""" % ( | ||
self._table)) |
58 changes: 58 additions & 0 deletions
58
account_budget_distribution/reports/crossovered_budget_resume_view.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,58 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="crossovered_budget_summary_view_form" model="ir.ui.view"> | ||
<field name="model">crossovered.budget.summary</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<sheet> | ||
<group name="main"> | ||
<field name="crossovered_budget_id" invisible="context.get('hide_budget_id',True)"/> | ||
<field name="general_budget_id" /> | ||
<field name="planned_amount" /> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="crossovered_budget_summary_view_tree" model="ir.ui.view"> | ||
<field name="model">crossovered.budget.summary</field> | ||
<field name="arch" type="xml"> | ||
<tree> | ||
<field name="crossovered_budget_id" invisible="context.get('hide_budget_id',True)" /> | ||
<field name="general_budget_id" /> | ||
<field name="planned_amount" sum="Total Planned Amount"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="crossovered_budget_summary_view_search" model="ir.ui.view"> | ||
<field name="model">crossovered.budget.summary</field> | ||
<field name="arch" type="xml"> | ||
<search> | ||
<field name="crossovered_budget_id" /> | ||
<field name="general_budget_id" /> | ||
<group name="group_by" expand="0"> | ||
<filter name="group_crossovered_budget" string="Budget" | ||
context="{'group_by': 'crossovered_budget_id'}" /> | ||
<filter name="group_general_budget" string="Budget Position" | ||
context="{'group_by': 'general_budget_id'}" /> | ||
</group> | ||
</search> | ||
</field> | ||
</record> | ||
|
||
<record id="action_crossovered_budget_summary_view" model="ir.actions.act_window"> | ||
<field name="name">Crossovered Budget Summary Lines</field> | ||
<field name="res_model">crossovered.budget.summary</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="context">{ | ||
'hide_budget_id': False, | ||
}</field> | ||
</record> | ||
|
||
<menuitem id="crossovered_budget_summary_option_view" | ||
action="action_crossovered_budget_summary_view" | ||
parent="account.account_management_menu"/> | ||
</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 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_crossovered_budget_summary,access_crossovered_budget_summary,model_crossovered_budget_summary,,1,0,0,0 |
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,4 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import test_account_budget_distribution |
46 changes: 46 additions & 0 deletions
46
account_budget_distribution/tests/test_account_budget_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,46 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo.addons.account_budget.tests.common import TestAccountBudgetCommon | ||
|
||
|
||
class TestAccountBudgetDistribution(TestAccountBudgetCommon): | ||
|
||
def test_account_budget_distribution(self): | ||
pessimistic_budget = self.browse_ref( | ||
'account_budget.crossovered_budget_budgetpessimistic0') | ||
self.assertTrue(pessimistic_budget.summary_ids) | ||
pessimistic_summary = pessimistic_budget.summary_ids | ||
wizard = self.env['crossovered.budget.distribution'].with_context( | ||
active_model=pessimistic_budget._name, | ||
active_id=pessimistic_budget.id).create({}) | ||
self.assertEquals(len(wizard.line_ids), len(pessimistic_summary)) | ||
planned_amounts = {} | ||
for line in wizard.line_ids: | ||
self.assertEquals( | ||
line.planned_amount, pessimistic_summary.filtered( | ||
lambda s: s.general_budget_id == line.budget_post_id | ||
).planned_amount) | ||
budget_lines = pessimistic_budget.crossovered_budget_line.filtered( | ||
lambda l: l.general_budget_id == line.budget_post_id) | ||
try: | ||
budget_lines = budget_lines.filtered( | ||
lambda l: not l.general_budget_id.expenses) | ||
except Exception: | ||
pass | ||
if budget_lines: | ||
planned_amounts.update({ | ||
line.budget_post_id.id: ( | ||
line.planned_amount / len(budget_lines)), | ||
}) | ||
wizard.button_distribute_amount() | ||
budget_lines = pessimistic_budget.crossovered_budget_line | ||
try: | ||
budget_lines = budget_lines.filtered( | ||
lambda l: not l.general_budget_id.expenses) | ||
except Exception: | ||
pass | ||
for budget_line in budget_lines: | ||
self.assertEquals( | ||
budget_line.planned_amount, | ||
planned_amounts[budget_line.general_budget_id.id]) |
17 changes: 17 additions & 0 deletions
17
account_budget_distribution/views/crossovered_budget_view.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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="crossovered_budget_view_form" model="ir.ui.view"> | ||
<field name="model">crossovered.budget</field> | ||
<field name="inherit_id" ref="account_budget.crossovered_budget_view_form" /> | ||
<field name="arch" type="xml"> | ||
<header position="inside"> | ||
<button name="%(action_crossovered_budget_distribution)d" string="Distribute Budget" type="action" /> | ||
</header> | ||
<notebook position="inside"> | ||
<page name="crossovered_budget_summary" string="Summary"> | ||
<field name="summary_ids" /> | ||
</page> | ||
</notebook> | ||
</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,4 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import crossovered_budget_distribution |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, correct author definition: