-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_budget_oca_analytic_tag + purchase_budget_oca_validation
- Loading branch information
Showing
22 changed files
with
721 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,24 @@ | ||
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
|
||
=============================== | ||
OSI Account Budget Analytic Tag | ||
=============================== | ||
|
||
This module allows you to select an analytic tag on the budget line and report the consumed budget using that tag. | ||
|
||
Usage | ||
===== | ||
|
||
No special usage instructions | ||
|
||
Credits | ||
======= | ||
|
||
* Maxime Chambreuil <[email protected]> | ||
|
||
Contributors | ||
------------ | ||
|
||
* Open Source Integrators <http://www.opensourceintegrators.com> |
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,3 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
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,20 @@ | ||
# Copyright (c) 2021 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "OSI Account Budget OCA Analytic Tag", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"summary": "This module allows you to select an analytic tag on the budget" | ||
" line and report the consumed budget using that tag.", | ||
"author": "Open Source Integrators", | ||
"maintainer": "Open Source Integrators", | ||
"website": "https://github.com/OCA/account-budgeting", | ||
"category": "Accounting", | ||
"depends": ["account_budget_oca"], | ||
"data": [ | ||
"views/account_budget_views.xml", | ||
], | ||
"installable": True, | ||
"maintainers": ["max3903"], | ||
} |
49 changes: 49 additions & 0 deletions
49
account_budget_oca_analytic_tag/i18n/account_budget_analytic_tag.pot
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,49 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_budget_analytic_tag | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0+e-20211202\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-12-23 19:57+0000\n" | ||
"PO-Revision-Date: 2021-12-23 19:57+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_analytic_tag | ||
#: model:ir.model.fields,field_description:account_budget_analytic_tag.field_crossovered_budget_lines__analytic_tag_id | ||
msgid "Analytic Tag" | ||
msgstr "" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: model:ir.model,name:account_budget_analytic_tag.model_crossovered_budget_lines | ||
msgid "Budget Line" | ||
msgstr "" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: model:ir.model.fields,field_description:account_budget_analytic_tag.field_crossovered_budget_lines__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: model:ir.model.fields,field_description:account_budget_analytic_tag.field_crossovered_budget_lines__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: model:ir.model.fields,field_description:account_budget_analytic_tag.field_crossovered_budget_lines____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: code:addons/account_budget_analytic_tag/models/account_budget.py:0 | ||
#, python-format | ||
msgid "" | ||
"You have to enter at least a budgetary position or analytic account or " | ||
"analytic tag on a budget line." | ||
msgstr "" |
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,51 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_budget_analytic_tag | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0+e-20211202\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-12-23 19:57+0000\n" | ||
"PO-Revision-Date: 2021-12-23 19:57+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_analytic_tag | ||
#: model:ir.model.fields,field_description:account_budget_analytic_tag.field_crossovered_budget_lines__analytic_tag_id | ||
msgid "Analytic Tag" | ||
msgstr "Etiqueta analítica" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: model:ir.model,name:account_budget_analytic_tag.model_crossovered_budget_lines | ||
msgid "Budget Line" | ||
msgstr "Línea de presupuesto" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: model:ir.model.fields,field_description:account_budget_analytic_tag.field_crossovered_budget_lines__display_name | ||
msgid "Display Name" | ||
msgstr "Nombre" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: model:ir.model.fields,field_description:account_budget_analytic_tag.field_crossovered_budget_lines__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: model:ir.model.fields,field_description:account_budget_analytic_tag.field_crossovered_budget_lines____last_update | ||
msgid "Last Modified on" | ||
msgstr "Ultima modificación el" | ||
|
||
#. module: account_budget_analytic_tag | ||
#: code:addons/account_budget_analytic_tag/models/account_budget.py:0 | ||
#, python-format | ||
msgid "" | ||
"You have to enter at least a budgetary position or analytic account or " | ||
"analytic tag on a budget line." | ||
msgstr "" | ||
"Deben entrar por lo menos una posicion presupuestarial, cuenta analítica o etiqueta " | ||
"analítica en una línea de presupuesto." |
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,3 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import account_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,71 @@ | ||
# Copyright (c) 2021 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class CrossoveredBudgetLines(models.Model): | ||
_inherit = "crossovered.budget.lines" | ||
|
||
analytic_tag_id = fields.Many2one("account.analytic.tag", string="Analytic Tag") | ||
|
||
def _compute_practical_amount(self): | ||
"""Overwrite this method for to count practical_amount based on | ||
analytic_tag_id on move line.""" | ||
for line in self: | ||
acc_ids = line.general_budget_id.account_ids.ids | ||
date_to = line.date_to | ||
date_from = line.date_from | ||
if line.analytic_account_id.id: | ||
self.env.cr.execute( | ||
""" | ||
SELECT SUM(amount) | ||
FROM account_analytic_line | ||
WHERE account_id=%s | ||
AND (date between %s | ||
AND %s) | ||
AND general_account_id=ANY(%s)""", | ||
(line.analytic_account_id.id, date_from, date_to, acc_ids), | ||
) | ||
result = self.env.cr.fetchone()[0] or 0.0 | ||
|
||
else: | ||
self.env.cr.execute( | ||
""" | ||
SELECT SUM(credit) - SUM(debit) | ||
FROM account_move_line aml | ||
LEFT JOIN account_move am ON aml.move_id = am.id | ||
LEFT JOIN | ||
account_analytic_tag_account_move_line_rel aat | ||
ON aat.account_move_line_id = aml.id | ||
WHERE state=%s | ||
AND account_id in %s | ||
AND (aml.date between %s | ||
AND %s) | ||
AND aat.account_analytic_tag_id=%s""", | ||
( | ||
"posted", | ||
tuple(line.general_budget_id.account_ids.ids), | ||
date_from, | ||
date_to, | ||
line.analytic_tag_id.id or 0.0, | ||
), | ||
) | ||
result = self.env.cr.fetchone()[0] | ||
line.practical_amount = result | ||
|
||
@api.constrains("general_budget_id", "analytic_account_id", "analytic_tag_id") | ||
def _must_have_analytical_or_budgetary_or_both(self): | ||
for record in self: | ||
if ( | ||
not record.analytic_account_id | ||
and not record.general_budget_id | ||
and not record.analytic_tag_id | ||
): | ||
raise ValidationError( | ||
_( | ||
"You have to enter at least a budgetary position or analytic account" | ||
" or analytic tag on a budget line." | ||
) | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions
41
account_budget_oca_analytic_tag/views/account_budget_views.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,41 @@ | ||
<odoo> | ||
|
||
<record | ||
id="crossovered_budget_view_form_inherit_account_budget_analytic_tag" | ||
model="ir.ui.view" | ||
> | ||
<field name="name">crossovered.budget.view.form.inherit.analytic_tag</field> | ||
<field name="model">crossovered.budget</field> | ||
<field | ||
name="inherit_id" | ||
ref="account_budget_oca.crossovered_budget_view_form" | ||
/> | ||
<field name="arch" type="xml"> | ||
<xpath | ||
expr="//page//tree//field[@name='analytic_account_id']" | ||
position="attributes" | ||
> | ||
<attribute name="required">0</attribute> | ||
</xpath> | ||
<xpath | ||
expr="//page//form//field[@name='analytic_account_id']" | ||
position="attributes" | ||
> | ||
<attribute name="required">0</attribute> | ||
</xpath> | ||
<xpath | ||
expr="//page//tree//field[@name='analytic_account_id']" | ||
position="after" | ||
> | ||
<field name="analytic_tag_id" /> | ||
</xpath> | ||
<xpath | ||
expr="//page//form//field[@name='analytic_account_id']" | ||
position="after" | ||
> | ||
<field name="analytic_tag_id" /> | ||
</xpath> | ||
</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,71 @@ | ||
========================== | ||
Purchase Budget Validation | ||
========================== | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
|
||
|badge1| |badge2| | ||
|
||
This module checks the purchase order lines amount against their related budgets and | ||
prevents you from going over budget. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
* Create a budget with either a budgetary position, an analytic account or analytic tag | ||
* Confirm it | ||
|
||
Usage | ||
===== | ||
|
||
* Create a purchase order and select a product, analytic account or tag that matches one of your budget lines. | ||
* Check for message in the chatter if you are over a budget. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/ursais/14.0/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 <https://github.com/ursais/14.0/issues/new?body=module:%20purchase_budget_validation%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Open Source Integrators | ||
* Serpent Consulting Services | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Maxime Chambreuil <[email protected]> | ||
* Hardik Suthar <[email protected]> | ||
|
||
Other credits | ||
~~~~~~~~~~~~~ | ||
|
||
The development of this module has been financially supported by: | ||
|
||
* Casai | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px | ||
:target: https://github.com/max3903 | ||
:alt: max3903 | ||
|
||
|maintainer-max3903| |
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,3 @@ | ||
# Copyright (c) 2022 Open Source Integrators | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
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,20 @@ | ||
# Copyright (c) 2022 Open Source Integrators | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
{ | ||
"name": "Purchase Budget OCA Validation", | ||
"version": "14.0.1.0.0", | ||
"author": "Open Source Integrators", | ||
"summary": "Check purchase orders against budgets", | ||
"license": "AGPL-3", | ||
"category": "Purchase", | ||
"maintainer": "Open Source Integrators", | ||
"website": "https://github.com/OCA/account-budgeting", | ||
"depends": ["purchase", "account_budget_oca_analytic_tag"], | ||
"installable": True, | ||
"maintainers": ["max3903"], | ||
"development_status": "Beta", | ||
"data": [ | ||
"views/crossovered_budget_lines_view.xml", | ||
"views/purchase_order_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,6 @@ | ||
# Copyright (c) 2022 Open Source Integrators | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
from . import crossovered_budget | ||
from . import crossovered_budget_lines | ||
from . import purchase_order | ||
from . import purchase_order_line |
11 changes: 11 additions & 0 deletions
11
purchase_budget_oca_validation/models/crossovered_budget.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,11 @@ | ||
# Copyright (c) 2022 Open Source Integrators | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
from odoo import fields, models | ||
|
||
|
||
class CrossoveredBudget(models.Model): | ||
_inherit = "crossovered.budget" | ||
|
||
amount_include_tax = fields.Boolean( | ||
"Include Taxes in Amount", default=False, copy=False | ||
) |
Oops, something went wrong.