Skip to content

Commit

Permalink
[IMP] project_budget: wizard to select budget date
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane committed Mar 4, 2019
1 parent faf8ae0 commit 3f74862
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 21 deletions.
1 change: 1 addition & 0 deletions project_budget/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import models
from . import wizards
1 change: 1 addition & 0 deletions project_budget/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
70 changes: 67 additions & 3 deletions project_budget/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand All @@ -126,13 +133,28 @@ 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
#: model:ir.ui.view,arch_db:project_budget.project_project_form_view2
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"
Expand All @@ -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
Expand Down Expand Up @@ -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 {}: {}"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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."
Expand Down Expand Up @@ -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"
Expand Down
16 changes: 10 additions & 6 deletions project_budget/models/project_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 0 additions & 12 deletions project_budget/views/project_project_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,4 @@
</field>
</record>

<record id="action_create_initial_project_budget"
model="ir.actions.server">
<field name="name">Create Initial Budget</field>
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="model_id" ref="project.model_project_project" />
<field name="binding_model_id" ref="project.model_project_project" />
<field name="code">
records.create_initial_project_budget()
</field>
</record>

</odoo>
4 changes: 4 additions & 0 deletions project_budget/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions project_budget/wizards/project_initial_budget.py
Original file line number Diff line number Diff line change
@@ -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)
28 changes: 28 additions & 0 deletions project_budget/wizards/project_initial_budget_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="project_initial_budget_view_form" model="ir.ui.view">
<field name="model">project.initial.budget</field>
<field name="arch" type="xml">
<form>
<group name="main">
<field name="project_ids" invisible="True"/>
<field name="date" required="True"/>
</group>
<footer>
<button name="create_initial_project_budget" type="object"
string="Create Initial Budget" class="oe_highlight" />
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>

<act_window id="project_initial_budget_wizard_action"
key2="client_action_multi"
name="Create Initial Budget"
res_model="project.initial.budget"
src_model="project.project"
view_mode="form"
target="new" />
</odoo>

0 comments on commit 3f74862

Please sign in to comment.