diff --git a/golem_resource_report/views/golem_resource_report_menu.xml b/golem_resource_report/views/golem_resource_report_menu.xml index 3facc13..ec823e4 100644 --- a/golem_resource_report/views/golem_resource_report_menu.xml +++ b/golem_resource_report/views/golem_resource_report_menu.xml @@ -2,11 +2,17 @@ - + + Resources Reports + golem.resource.report.wizard + form + form + + {} + new + - diff --git a/golem_resource_report/wizard/golem_resource_report_wizard.py b/golem_resource_report/wizard/golem_resource_report_wizard.py index 5941c40..cb0dafe 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard.py +++ b/golem_resource_report/wizard/golem_resource_report_wizard.py @@ -18,21 +18,27 @@ """ GOLEM Resources management """ -from odoo import models, fields, api +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError class GolemResourceReportWizard(models.TransientModel): """GOLEM Resource wizard : refusal reason for a reservation """ _name = "golem.resource.report.wizard" - def _get_resources(self): - return self.env['golem.resource'].search([]).ids - resource_ids = fields.Many2many('golem.resource',default=_get_resources) - selected_resource_ids = fields.Many2many('golem.resource', - domaine="[('id', in, resources_ids.ids)]") + resource_ids = fields.Many2many('golem.resource') date_start = fields.Datetime(required=True) date_stop = fields.Datetime(required=True) @api.multi def print_report(self): for record in self: - pass + start_date = fields.Datetime.from_string(record.date_start) + stop_date = fields.Datetime.from_string(record.date_stop) + if start_date > stop_date: + raise ValidationError(_("Stop Date cannot be set before \ + Start Date.")) + else: + domain = [('date_start', '>', record.date_start), + ('date_stop', '<', record.date_stop), + ('resource_id', 'in', record.selected_resource_ids.ids)] + data = self.env['golem.resource.reservation'].search(domain) diff --git a/golem_resource_report/wizard/golem_resource_report_wizard_views.xml b/golem_resource_report/wizard/golem_resource_report_wizard_views.xml index 3d226bd..07aa754 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard_views.xml +++ b/golem_resource_report/wizard/golem_resource_report_wizard_views.xml @@ -27,22 +27,21 @@ along with this program. If not, see .
- - - - - - - - - - - + + + + + + + + + +