From 3f748628ed6a8220d40c399bbf2955d4d9ae8d8c Mon Sep 17 00:00:00 2001 From: Oihane Crucelaegui Date: Mon, 4 Mar 2019 13:52:25 +0100 Subject: [PATCH] [IMP] project_budget: wizard to select budget date --- project_budget/__init__.py | 1 + project_budget/__manifest__.py | 1 + project_budget/i18n/es.po | 70 ++++++++++++++++++- project_budget/models/project_project.py | 16 +++-- project_budget/views/project_project_view.xml | 12 ---- project_budget/wizards/__init__.py | 4 ++ .../wizards/project_initial_budget.py | 27 +++++++ .../wizards/project_initial_budget_view.xml | 28 ++++++++ 8 files changed, 138 insertions(+), 21 deletions(-) create mode 100644 project_budget/wizards/__init__.py create mode 100644 project_budget/wizards/project_initial_budget.py create mode 100644 project_budget/wizards/project_initial_budget_view.xml diff --git a/project_budget/__init__.py b/project_budget/__init__.py index 288dc48e..98e8fe7b 100644 --- a/project_budget/__init__.py +++ b/project_budget/__init__.py @@ -2,3 +2,4 @@ # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import models +from . import wizards diff --git a/project_budget/__manifest__.py b/project_budget/__manifest__.py index cc96f7f6..81e4dc5e 100644 --- a/project_budget/__manifest__.py +++ b/project_budget/__manifest__.py @@ -26,6 +26,7 @@ "views/project_project_view.xml", "views/account_analytic_account_view.xml", "views/res_config_settings_view.xml", + "wizards/project_initial_budget_view.xml", ], "installable": True, } diff --git a/project_budget/i18n/es.po b/project_budget/i18n/es.po index 63f2f9f2..7b99dc45 100644 --- a/project_budget/i18n/es.po +++ b/project_budget/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-01-29 10:27+0000\n" -"PO-Revision-Date: 2019-01-29 10:27+0000\n" +"POT-Creation-Date: 2019-03-04 12:42+0000\n" +"PO-Revision-Date: 2019-03-04 12:42+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -66,6 +66,7 @@ msgstr "Presupuesto activado" #. module: project_budget #: model:ir.model.fields,field_description:project_budget.field_crossovered_budget_budget_date #: model:ir.model.fields,field_description:project_budget.field_crossovered_budget_lines_budget_date +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget_date msgid "Budget Date" msgstr "Fecha del presupuesto" @@ -106,13 +107,19 @@ msgstr "Presupuestos" msgid "By keeping track of where your money goes, you may be less likely to overspend, and more likely to meet your financial goals. Forecast a budget by detailing the expected revenue per analytic account and monitor its evolution based on the actuals realised during that period." msgstr "Haciendo un seguimiento de dónde va su dinero, puede ser menos probable gastar demasiado, y más probable alcanzar sus metas financieras. Prevea un presupuesto detallando los ingresos esperados por cuenta analítica y monitorice su evolución basada en lo real obtenido durante ese periodo." +#. module: project_budget +#: model:ir.ui.view,arch_db:project_budget.project_initial_budget_view_form +msgid "Cancel" +msgstr "Cancelar" + #. module: project_budget #: model:ir.actions.act_window,help:project_budget.project_budget_action msgid "Click to create a new budget." msgstr "Pulse para crear un nuevo presupuesto." #. module: project_budget -#: model:ir.actions.server,name:project_budget.action_create_initial_project_budget +#: model:ir.actions.act_window,name:project_budget.project_initial_budget_wizard_action +#: model:ir.ui.view,arch_db:project_budget.project_initial_budget_view_form msgid "Create Initial Budget" msgstr "Crear presupuesto inicial" @@ -126,6 +133,16 @@ msgstr "Crear elementos" msgid "Create a line on december 30th as summary" msgstr "Crear una línea el día 30 de diciembre como resumen" +#. module: project_budget +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget_create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: project_budget +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget_create_date +msgid "Created on" +msgstr "Creado en" + #. module: project_budget #: model:ir.model.fields,field_description:project_budget.field_project_project_current_budget_id #: model:ir.ui.view,arch_db:project_budget.crossovered_budget_search_view @@ -133,6 +150,11 @@ msgstr "Crear una línea el día 30 de diciembre como resumen" msgid "Current Budget" msgstr "Presupuesto actual" +#. module: project_budget +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget_display_name +msgid "Display Name" +msgstr "Nombre mostrado" + #. module: project_budget #: model:ir.ui.view,arch_db:project_budget.crossovered_budget_line_search_view msgid "Group By" @@ -143,6 +165,11 @@ msgstr "Agrupar por" msgid "Has Current Budget" msgstr "Tiene presupuesto actual" +#. module: project_budget +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget_id +msgid "ID" +msgstr "ID (identificación)" + #. module: project_budget #: model:ir.model.fields,field_description:project_budget.field_crossovered_budget_initial #: model:ir.ui.view,arch_db:project_budget.crossovered_budget_search_view @@ -173,6 +200,7 @@ msgstr "Importe planificado inicial" #. module: project_budget #: code:addons/project_budget/models/project_project.py:68 +#: code:addons/project_budget/wizards/project_initial_budget.py:38 #, python-format msgid "Initial {} budget: {}" msgstr "Presupuesto inicial {}: {}" @@ -187,6 +215,21 @@ msgstr "Creará una línea con fecha 30 de diciembre del último año." msgid "It will create a line on december 30th, if more than one year is selected only for the last year." msgstr "Creará una línea con fecha de 30 de diciembre, si se han seleccionado más de un año se pondrá en el último año." +#. module: project_budget +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget___last_update +msgid "Last Modified on" +msgstr "Última modificación en" + +#. module: project_budget +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget_write_uid +msgid "Last Updated by" +msgstr "Última actualización de" + +#. module: project_budget +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget_write_date +msgid "Last Updated on" +msgstr "Última actualización en" + #. module: project_budget #: model:ir.model.fields,field_description:project_budget.field_crossovered_budget_lines_notes #: model:ir.ui.view,arch_db:project_budget.crossovered_budget_form_view @@ -198,6 +241,7 @@ msgstr "Notas" #: model:ir.model,name:project_budget.model_project_project #: model:ir.model.fields,field_description:project_budget.field_crossovered_budget_lines_project_id #: model:ir.model.fields,field_description:project_budget.field_crossovered_budget_project_id +#: model:ir.model.fields,field_description:project_budget.field_project_initial_budget_project_ids #: model:ir.ui.view,arch_db:project_budget.crossovered_budget_line_search_view msgid "Project" msgstr "Proyecto" @@ -207,11 +251,21 @@ msgstr "Proyecto" msgid "Project Budget" msgstr "Presupuesto de proyecto" +#. module: project_budget +#: model:ir.actions.server,name:project_budget.action_budget_line_compute_amount +msgid "Recompute Amounts" +msgstr "Recalcular valores" + #. module: project_budget #: model:ir.ui.view,arch_db:project_budget.crossovered_budget_form_view msgid "Recompute Line Amount" msgstr "Recalcular importes" +#. module: project_budget +#: model:ir.actions.server,name:project_budget.action_budget_compute_amount +msgid "Recompute Line Amounts" +msgstr "Recalcular valores de las líneas" + #. module: project_budget #: model:ir.ui.view,arch_db:project_budget.project_config_settings_form_view msgid "Show a smartbutton to access directly to current month budget." @@ -249,11 +303,21 @@ msgstr "Esto recalculará las columnas 'Contabilizado' y 'Previsión final', est msgid "Unbudgeted" msgstr "Sin presupuestar" +#. module: project_budget +#: model:ir.model,name:project_budget.model_project_initial_budget +msgid "Wizard to create initial budget" +msgstr "Asistente para crear presupuesto inicial" + #. module: project_budget #: model:ir.model.fields,field_description:project_budget.field_crossovered_budget_year msgid "Year" msgstr "Año" +#. module: project_budget +#: model:ir.ui.view,arch_db:project_budget.project_initial_budget_view_form +msgid "or" +msgstr "o" + #. module: project_budget #: model:ir.model,name:project_budget.model_res_config_settings msgid "res.config.settings" diff --git a/project_budget/models/project_project.py b/project_budget/models/project_project.py index 019f901d..e3f4aeee 100644 --- a/project_budget/models/project_project.py +++ b/project_budget/models/project_project.py @@ -57,20 +57,24 @@ def _search_current_budget(self, operator, value): return [('id', operator, current_budgets.mapped('project_id').ids)] @api.multi - def create_initial_project_budget(self): + def create_initial_project_budget(self, date=False): + if not date: + date = fields.Date.context_today(self) budget_obj = self.env['crossovered.budget'] - today = from_string(fields.Date.context_today(self)) - date_from = to_string(today.replace(month=1, day=1)) - date_to = to_string(today.replace(month=12, day=31)) + budget_date = from_string(date) + date_from = to_string(budget_date.replace(month=1, day=1)) + date_to = to_string(budget_date.replace(month=12, day=31)) for record in self.filtered(lambda l: not any(l.budget_ids.filtered( - lambda b: b.initial and b.year == today.year))): + lambda b: b.initial and b.year == budget_date.year))): budget = budget_obj.create({ 'name': _( - u'Initial {} budget: {}').format(today.year, record.name), + u'Initial {} budget: {}').format(budget_date.year, + record.name), 'initial': True, 'creating_user_id': record.user_id.id, 'date_from': date_from, 'date_to': date_to, + 'budget_date': budget_date, 'project_id': record.id, }) budget.button_compute_lines() diff --git a/project_budget/views/project_project_view.xml b/project_budget/views/project_project_view.xml index b40e1f8b..107c42f8 100644 --- a/project_budget/views/project_project_view.xml +++ b/project_budget/views/project_project_view.xml @@ -77,16 +77,4 @@ - - Create Initial Budget - ir.actions.server - code - - - -records.create_initial_project_budget() - - - diff --git a/project_budget/wizards/__init__.py b/project_budget/wizards/__init__.py new file mode 100644 index 00000000..b922a7e3 --- /dev/null +++ b/project_budget/wizards/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2019 Oihane Crucelaegui - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import project_initial_budget diff --git a/project_budget/wizards/project_initial_budget.py b/project_budget/wizards/project_initial_budget.py new file mode 100644 index 00000000..e1aefc06 --- /dev/null +++ b/project_budget/wizards/project_initial_budget.py @@ -0,0 +1,27 @@ +# Copyright 2019 Oihane Crucelaegui - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class ProjectInitialBudget(models.TransientModel): + _name = 'project.initial.budget' + _description = 'Wizard to create initial budget' + + project_ids = fields.Many2many( + comodel_name='project.project', string='Project') + date = fields.Date( + string='Budget Date', default=lambda s: fields.Date.context_today(s)) + + @api.model + def default_get(self, fields): + rec = super(ProjectInitialBudget, self).default_get(fields) + rec.update({ + 'project_ids': [(6, 0, self.env.context.get('active_ids'))], + }) + return rec + + @api.multi + def create_initial_project_budget(self): + self.ensure_one() + self.project_ids.create_initial_project_budget(date=self.date) diff --git a/project_budget/wizards/project_initial_budget_view.xml b/project_budget/wizards/project_initial_budget_view.xml new file mode 100644 index 00000000..0eba7f51 --- /dev/null +++ b/project_budget/wizards/project_initial_budget_view.xml @@ -0,0 +1,28 @@ + + + + project.initial.budget + +
+ + + + +
+
+
+
+
+ + +