diff --git a/account_move_budget/README.rst b/account_move_budget/README.rst new file mode 100644 index 000000000..8bd665a9c --- /dev/null +++ b/account_move_budget/README.rst @@ -0,0 +1,105 @@ +=================== +Account Move Budget +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-tools/tree/11.0/account_move_budget + :alt: OCA/account-financial-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-tools-11-0/account-financial-tools-11-0-account_move_budget + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/92/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to define accounting budgets. + +These budgets can then be used in MIS Builder reports, as an alternate +source. + +The difference between the MIS Builder Budget and this module is that +this module defines budgets irrespective of the MIS Builder Template. The +budget is thus agnostic of the reporting format. + +For example, the budgeted data can be used in a general Profit & Loss report +and at the same time can be used in a department or project expenses report. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +[ This file is optional, it should explain how to configure + the module before using it; it is aimed at advanced users. ] + +To configure this module, you need to: + +#. Go to ... + +.. figure:: ../static/description/image.png + :alt: alternative description + :width: 600 px + +Usage +===== + +In order to set up the budget items go to +*Invoicing / Adviser / Accounting Entries / Account Move Budgets*. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Eficent + +Contributors +~~~~~~~~~~~~ + +* Eficent Business and IT Consulting Services, S.L. (https://www.eficent.com) + * Hector Villarreal + * Jordi Ballester Alomar + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/account-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_move_budget/__init__.py b/account_move_budget/__init__.py new file mode 100644 index 000000000..fd4608058 --- /dev/null +++ b/account_move_budget/__init__.py @@ -0,0 +1,3 @@ + +from . import models + diff --git a/account_move_budget/__manifest__.py b/account_move_budget/__manifest__.py new file mode 100644 index 000000000..099fd8690 --- /dev/null +++ b/account_move_budget/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Move Budget", + "summary": "Create Accounting Budgets", + "version": "11.0.1.0.0", + "category": "Accounting & Finance", + "website": "https://github.com/OCA/account-financial-tools", + "author": "Eficent, " + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "account", + "date_range", + ], + "data": [ + "security/ir.model.access.csv", + "views/account_move_budget_line_views.xml", + "views/account_move_budget_views.xml", + ], +} diff --git a/account_move_budget/models/__init__.py b/account_move_budget/models/__init__.py new file mode 100644 index 000000000..be082f2c6 --- /dev/null +++ b/account_move_budget/models/__init__.py @@ -0,0 +1,3 @@ + +from . import account_move_budget +from . import account_move_budget_line diff --git a/account_move_budget/models/account_move_budget.py b/account_move_budget/models/account_move_budget.py new file mode 100644 index 000000000..f7fece39b --- /dev/null +++ b/account_move_budget/models/account_move_budget.py @@ -0,0 +1,95 @@ +# Copyright 2019 ACSONE SA/NV +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models + + +class AccountMoveBudget(models.Model): + _name = "account.move.budget" + _description = "Account Move Budget" + _inherit = ['mail.thread', 'mail.activity.mixin'] + + @api.model + def _default_company(self): + return self.env['res.company']. \ + _company_default_get('mis.budget') + + name = fields.Char( + required=True, + track_visibility='onchange', + ) + description = fields.Char( + track_visibility='onchange', + ) + date_range_id = fields.Many2one( + comodel_name='date.range', + string='Date range', + ) + date_from = fields.Date( + required=True, + string='From', + track_visibility='onchange', + ) + date_to = fields.Date( + required=True, + string='To', + track_visibility='onchange', + ) + state = fields.Selection( + [('draft', 'Draft'), + ('confirmed', 'Confirmed'), + ('cancelled', 'Cancelled')], + required=True, + default='draft', + track_visibility='onchange', + ) + line_ids = fields.One2many( + comodel_name='account.move.budget.line', + inverse_name='budget_id', + copy=True, + ) + company_id = fields.Many2one( + comodel_name='res.company', + string='Company', + default=_default_company, + ) + + @api.multi + def copy(self, default=None): + self.ensure_one() + if default is None: + default = {} + if 'name' not in default: + default['name'] = _("%s (copy)") % self.name + return super(AccountMoveBudget, self).copy(default=default) + + @api.onchange('date_range_id') + def _onchange_date_range(self): + for rec in self: + if rec.date_range_id: + rec.date_from = rec.date_range_id.date_start + rec.date_to = rec.date_range_id.date_end + + @api.onchange('date_from', 'date_to') + def _onchange_dates(self): + for rec in self: + if rec.date_range_id: + if rec.date_from != rec.date_range_id.date_start or \ + rec.date_to != rec.date_range_id.date_end: + rec.date_range_id = False + + @api.multi + def action_draft(self): + for rec in self: + rec.state = 'draft' + + @api.multi + def action_cancel(self): + for rec in self: + rec.state = 'cancelled' + + @api.multi + def action_confirm(self): + for rec in self: + rec.state = 'confirmed' diff --git a/account_move_budget/models/account_move_budget_line.py b/account_move_budget/models/account_move_budget_line.py new file mode 100644 index 000000000..26354627f --- /dev/null +++ b/account_move_budget/models/account_move_budget_line.py @@ -0,0 +1,87 @@ +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class AccountMoveBudgetLine(models.Model): + _name = "account.move.budget.line" + _description = "Account Move Budget Line" + _order = "date desc, id desc" + + budget_id = fields.Many2one( + comodel_name='account.move.budget', + string="Budget", + required=True, + ondelete='cascade', + index=True, + ) + name = fields.Char(string="Label") + debit = fields.Monetary( + default=0.0, + currency_field='company_currency_id', + ) + credit = fields.Monetary( + default=0.0, + currency_field='company_currency_id' + ) + balance = fields.Monetary( + compute='_compute_store_balance', + store=True, + currency_field='company_currency_id', + help="Technical field holding the debit - " + "credit in order to open meaningful " + "graph views from reports", + ) + company_currency_id = fields.Many2one( + 'res.currency', + related='company_id.currency_id', + string="Company Currency", + readonly=True, + help='Utility field to express amount currency', + store=True, + ) + account_id = fields.Many2one( + 'account.account', + string='Account', + required=True, + index=True, + ondelete="cascade", + domain=[('deprecated', '=', False)], + default=lambda self: self._context.get('account_id', False), + ) + date = fields.Date( + string='Date', + index=True, + required=True, + ) + analytic_account_id = fields.Many2one( + 'account.analytic.account', + string='Analytic Account', + ) + company_id = fields.Many2one( + 'res.company', + related='account_id.company_id', + string='Company', + store=True, + readonly=True, + ) + partner_id = fields.Many2one( + 'res.partner', + string='Partner', + ondelete='restrict', + ) + + @api.depends('debit', 'credit') + def _compute_store_balance(self): + for line in self: + line.balance = line.debit - line.credit + + @api.constrains('date') + def _constraint_date(self): + for rec in self: + if rec.budget_id.date_from > rec.date or \ + rec.budget_id.date_to < rec.date: + raise ValidationError(_('The date must be within the ' + 'budget period.')) diff --git a/account_move_budget/readme/CONTRIBUTORS.rst b/account_move_budget/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9f9d8f9d6 --- /dev/null +++ b/account_move_budget/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Eficent Business and IT Consulting Services, S.L. (https://www.eficent.com) + * Hector Villarreal + * Jordi Ballester Alomar diff --git a/account_move_budget/readme/DESCRIPTION.rst b/account_move_budget/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b56898e3d --- /dev/null +++ b/account_move_budget/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +This module allows to define accounting budgets. + +These budgets can then be used in MIS Builder reports, as an alternate +source. + +The difference between the MIS Builder Budget and this module is that +this module defines budgets irrespective of the MIS Builder Template. The +budget is thus agnostic of the reporting format. + +For example, the budgeted data can be used in a general Profit & Loss report +and at the same time can be used in a department or project expenses report. diff --git a/account_move_budget/readme/USAGE.rst b/account_move_budget/readme/USAGE.rst new file mode 100644 index 000000000..dda038e0e --- /dev/null +++ b/account_move_budget/readme/USAGE.rst @@ -0,0 +1,2 @@ +In order to set up the budget items go to +*Invoicing / Adviser / Accounting Entries / Account Move Budgets*. diff --git a/account_move_budget/security/ir.model.access.csv b/account_move_budget/security/ir.model.access.csv new file mode 100644 index 000000000..abe158087 --- /dev/null +++ b/account_move_budget/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_move_budget,access_account_move_budget,model_account_move_budget,account.group_account_user,1,0,0,0 +access_account_move_budget_manager,access_account_move_budget_manager,model_account_move_budget,account.group_account_manager,1,1,1,1 +access_account_move_budget_line,access_account_move_budget_line,model_account_move_budget_line,account.group_account_user,1,0,0,0 +access_account_move_budget_line_manager,access_account_move_budget_line_manager,model_account_move_budget_line,account.group_account_manager,1,1,1,1 diff --git a/account_move_budget/static/description/icon.png b/account_move_budget/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_move_budget/static/description/icon.png differ diff --git a/account_move_budget/static/description/index.html b/account_move_budget/static/description/index.html new file mode 100644 index 000000000..11bc4e8be --- /dev/null +++ b/account_move_budget/static/description/index.html @@ -0,0 +1,449 @@ + + + + + + +Account Move Budget + + + +
+

Account Move Budget

+ + +

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

This module allows to define accounting budgets.

+

These budgets can then be used in MIS Builder reports, as an alternate +source.

+

The difference between the MIS Builder Budget and this module is that +this module defines budgets irrespective of the MIS Builder Template. The +budget is thus agnostic of the reporting format.

+

For example, the budgeted data can be used in a general Profit & Loss report +and at the same time can be used in a department or project expenses report.

+

Table of contents

+ +
+

Configuration

+
+
[ This file is optional, it should explain how to configure
+
the module before using it; it is aimed at advanced users. ]
+
+

To configure this module, you need to:

+
    +
  1. Go to …
  2. +
+
+alternative description +
+
+
+

Usage

+

In order to set up the budget items go to +Invoicing / Adviser / Accounting Entries / Account Move Budgets.

+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Eficent
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/account-financial-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_move_budget/views/account_move_budget_line_views.xml b/account_move_budget/views/account_move_budget_line_views.xml new file mode 100644 index 000000000..12bf7a7f7 --- /dev/null +++ b/account_move_budget/views/account_move_budget_line_views.xml @@ -0,0 +1,33 @@ + + + + + + Account Move Budget Line tree + account.move.budget.line + + + + + + + + + + + + + + + + + + Budget Items + account.move.budget.line + tree + [('budget_id', '=', active_id)] + {'default_budget_id': active_id} + + + diff --git a/account_move_budget/views/account_move_budget_views.xml b/account_move_budget/views/account_move_budget_views.xml new file mode 100644 index 000000000..adbe4a6a2 --- /dev/null +++ b/account_move_budget/views/account_move_budget_views.xml @@ -0,0 +1,92 @@ + + + + + + + account.move.budget.form + account.move.budget + +
+
+
+ +
+
+
+
+
+

+ +

+ +
+ + + + + + + + +
+
+ + + +
+
+
+
+ + + account.move.budget.search + account.move.budget + + + + + + + + + + account.move.budget.tree + account.move.budget + + + + + + + + + + + + Account Move Budgets + account.move.budget + tree,form + [] + {} + + + + Account Move Budgets + + + + +