diff --git a/account_move_budget/README.rst b/account_move_budget/README.rst new file mode 100644 index 000000000..45e4baac3 --- /dev/null +++ b/account_move_budget/README.rst @@ -0,0 +1,91 @@ +=================== +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/12.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-12-0/account-financial-tools-12-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/12.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: + +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..7283e69e1 --- /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": "12.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/i18n/account_move_budget.pot b/account_move_budget/i18n/account_move_budget.pot new file mode 100644 index 000000000..3562a34df --- /dev/null +++ b/account_move_budget/i18n/account_move_budget.pot @@ -0,0 +1,227 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_budget +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \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_move_budget +#: code:addons/account_move_budget/models/account_move_budget.py:64 +#, python-format +msgid "%s (copy)" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_account_id +msgid "Account" +msgstr "" + +#. module: account_move_budget +#: model:ir.model,name:account_move_budget.model_account_move_budget +msgid "Account Move Budget" +msgstr "" + +#. module: account_move_budget +#: model:ir.model,name:account_move_budget.model_account_move_budget_line +msgid "Account Move Budget Line" +msgstr "" + +#. module: account_move_budget +#: model:ir.actions.act_window,name:account_move_budget.account_move_budget_act_window +#: model:ir.ui.menu,name:account_move_budget.account_move_budget_menu +msgid "Account Move Budgets" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_analytic_account_id +msgid "Analytic Account" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_balance +msgid "Balance" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_budget_id +msgid "Budget" +msgstr "" + +#. module: account_move_budget +#: model:ir.actions.act_window,name:account_move_budget.account_move_budget_line_act_window +msgid "Budget Items" +msgstr "" + +#. module: account_move_budget +#: model:ir.ui.view,arch_db:account_move_budget.account_move_budget_form_view +msgid "Budget Lines" +msgstr "" + +#. module: account_move_budget +#: model:ir.ui.view,arch_db:account_move_budget.account_move_budget_form_view +msgid "Cancel" +msgstr "" + +#. module: account_move_budget +#: selection:account.move.budget,state:0 +msgid "Cancelled" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_company_id +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_company_id +msgid "Company" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_company_currency_id +msgid "Company Currency" +msgstr "" + +#. module: account_move_budget +#: model:ir.ui.view,arch_db:account_move_budget.account_move_budget_form_view +msgid "Confirm" +msgstr "" + +#. module: account_move_budget +#: selection:account.move.budget,state:0 +msgid "Confirmed" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_create_uid +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_create_uid +msgid "Created by" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_create_date +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_create_date +msgid "Created on" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_credit +msgid "Credit" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_date +msgid "Date" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_date_range_id +msgid "Date range" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_debit +msgid "Debit" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_description +msgid "Description" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_display_name +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_display_name +msgid "Display Name" +msgstr "" + +#. module: account_move_budget +#: selection:account.move.budget,state:0 +msgid "Draft" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_date_from +msgid "From" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_id +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_id +msgid "ID" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_name +msgid "Label" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget___last_update +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line___last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_write_uid +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_write_date +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_write_date +msgid "Last Updated on" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_ids +msgid "Line" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_name +#: model:ir.ui.view,arch_db:account_move_budget.account_move_budget_form_view +msgid "Name" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_line_partner_id +msgid "Partner" +msgstr "" + +#. module: account_move_budget +#: model:ir.ui.view,arch_db:account_move_budget.account_move_budget_form_view +msgid "Set draft" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_state +msgid "State" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,help:account_move_budget.field_account_move_budget_line_balance +msgid "Technical field holding the debit - credit in order to open meaningful graph views from reports" +msgstr "" + +#. module: account_move_budget +#: code:addons/account_move_budget/models/account_move_budget_line.py:86 +#, python-format +msgid "The date must be within the budget period." +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,field_description:account_move_budget.field_account_move_budget_date_to +msgid "To" +msgstr "" + +#. module: account_move_budget +#: model:ir.model.fields,help:account_move_budget.field_account_move_budget_line_company_currency_id +msgid "Utility field to express amount currency" +msgstr "" + 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..d259ac62b --- /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 Date', + track_visibility='onchange', + ) + date_to = fields.Date( + required=True, + string='To Date', + 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..371dc566b --- /dev/null +++ b/account_move_budget/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +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

+ +
+

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 + + + + +