From 3c2ce0ceba2a381e525d1ca991f939e71e0877d5 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Mon, 9 Apr 2018 18:49:50 +0200 Subject: [PATCH 01/15] =?UTF-8?q?modification=20du=20calcul=20du=20quantit?= =?UTF-8?q?=C3=A9=20selon=20uom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/golem_resource_reservation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index a18ad91..c91bf71 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -75,8 +75,11 @@ class GolemResourceReservation(models.Model): product.categ_id.property_account_income_categ_id.id delta = fields.Datetime.from_string(reservation.date_stop) - \ fields.Datetime.from_string(reservation.date_start) - quantity = (delta.days * 24) + (delta.seconds/3600.0) - + quantity = 1 + if product.uom_id.name == 'Hour(s)' or product.uom_id.name == 'Unit(s)': + quantity = int((delta.days * 24) + (delta.seconds/3600.0)) + elif product.uom_id.name == 'Day(s)': + quantity = int(delta.days + (delta.seconds/86400.0))#number of seconds in a day line_id = self.env['account.invoice.line'].create({ 'invoice_id': invoice_id.id, 'name': product.name, From 2abaabc002d0e03cd1bb918894effe02c80c6d81 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 11 Apr 2018 21:27:07 +0200 Subject: [PATCH 02/15] wizard pour choisir les resources --- golem_resource_report/__init__.py | 20 +++++++ golem_resource_report/__manifest__.py | 33 ++++++++++++ .../reports/golem_reservation_report.xml | 8 +++ .../views/golem_resource_report_menu.xml | 14 +++++ golem_resource_report/wizard/__init__.py | 19 +++++++ .../wizard/golem_resource_report_wizard.py | 38 ++++++++++++++ .../golem_resource_report_wizard_views.xml | 52 +++++++++++++++++++ 7 files changed, 184 insertions(+) create mode 100644 golem_resource_report/__init__.py create mode 100644 golem_resource_report/__manifest__.py create mode 100644 golem_resource_report/reports/golem_reservation_report.xml create mode 100644 golem_resource_report/views/golem_resource_report_menu.xml create mode 100644 golem_resource_report/wizard/__init__.py create mode 100644 golem_resource_report/wizard/golem_resource_report_wizard.py create mode 100644 golem_resource_report/wizard/golem_resource_report_wizard_views.xml diff --git a/golem_resource_report/__init__.py b/golem_resource_report/__init__.py new file mode 100644 index 0000000..27ce4b7 --- /dev/null +++ b/golem_resource_report/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#from . import models +from . import wizard diff --git a/golem_resource_report/__manifest__.py b/golem_resource_report/__manifest__.py new file mode 100644 index 0000000..4b14908 --- /dev/null +++ b/golem_resource_report/__manifest__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +{ + 'name': 'GOLEM resources reports', + 'summary': 'GOLEM resources reports', + 'description': ''' GOLEM resources reports ''', + 'version': '10.0.0.0.0', + 'category': 'GOLEM', + 'author': 'Youssef El Ouahby, Fabien Bourgeois', + 'license': 'AGPL-3', + 'application': True, + 'installable': True, + 'depends': ['golem_resource'], + 'data': ['reports/golem_reservation_report.xml', + 'views/golem_resource_report_menu.xml', + 'wizard/golem_resource_report_wizard_views.xml'] +} diff --git a/golem_resource_report/reports/golem_reservation_report.xml b/golem_resource_report/reports/golem_reservation_report.xml new file mode 100644 index 0000000..71bdca2 --- /dev/null +++ b/golem_resource_report/reports/golem_reservation_report.xml @@ -0,0 +1,8 @@ + + + + diff --git a/golem_resource_report/views/golem_resource_report_menu.xml b/golem_resource_report/views/golem_resource_report_menu.xml new file mode 100644 index 0000000..3facc13 --- /dev/null +++ b/golem_resource_report/views/golem_resource_report_menu.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/golem_resource_report/wizard/__init__.py b/golem_resource_report/wizard/__init__.py new file mode 100644 index 0000000..5ae7a4c --- /dev/null +++ b/golem_resource_report/wizard/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import golem_resource_report_wizard diff --git a/golem_resource_report/wizard/golem_resource_report_wizard.py b/golem_resource_report/wizard/golem_resource_report_wizard.py new file mode 100644 index 0000000..5941c40 --- /dev/null +++ b/golem_resource_report/wizard/golem_resource_report_wizard.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Resources management """ + +from odoo import models, fields, api + +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)]") + date_start = fields.Datetime(required=True) + date_stop = fields.Datetime(required=True) + + @api.multi + def print_report(self): + for record in self: + pass diff --git a/golem_resource_report/wizard/golem_resource_report_wizard_views.xml b/golem_resource_report/wizard/golem_resource_report_wizard_views.xml new file mode 100644 index 0000000..3d226bd --- /dev/null +++ b/golem_resource_report/wizard/golem_resource_report_wizard_views.xml @@ -0,0 +1,52 @@ + + + + + + + + GOLEM resource Report Wizard Form + golem.resource.report.wizard + +
+ + + + + + + + + + + + + + +
+
+
+
+
+ +
+
From c669ddae2f9bb5801ca9681af6405f6ac8522344 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Thu, 12 Apr 2018 00:52:05 +0200 Subject: [PATCH 03/15] code refactoring --- .../views/golem_resource_report_menu.xml | 12 +++++++--- .../wizard/golem_resource_report_wizard.py | 20 ++++++++++------ .../golem_resource_report_wizard_views.xml | 23 +++++++++---------- 3 files changed, 33 insertions(+), 22 deletions(-) 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 .
- - - - - - - - - - - + + + + + + + + + +
From 01a34e0e3befba759eb111840b504e423f2335ca Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Thu, 12 Apr 2018 18:25:57 +0200 Subject: [PATCH 04/15] fonction de reporting --- golem_resource_report/__init__.py | 1 + golem_resource_report/__manifest__.py | 1 + golem_resource_report/reports/__init__.py | 19 +++++ .../reports/golem_reservation_report.py | 79 +++++++++++++++++++ .../reports/golem_reservation_report.xml | 66 ++++++++++++++-- .../reports/golem_reservation_report_menu.xml | 49 ++++++++++++ .../views/golem_resource_report_menu.xml | 18 +++++ .../wizard/golem_resource_report_wizard.py | 11 ++- .../golem_resource_report_wizard_views.xml | 6 +- 9 files changed, 236 insertions(+), 14 deletions(-) create mode 100644 golem_resource_report/reports/__init__.py create mode 100644 golem_resource_report/reports/golem_reservation_report.py create mode 100644 golem_resource_report/reports/golem_reservation_report_menu.xml diff --git a/golem_resource_report/__init__.py b/golem_resource_report/__init__.py index 27ce4b7..f1d4cf2 100644 --- a/golem_resource_report/__init__.py +++ b/golem_resource_report/__init__.py @@ -18,3 +18,4 @@ #from . import models from . import wizard +from . import reports diff --git a/golem_resource_report/__manifest__.py b/golem_resource_report/__manifest__.py index 4b14908..d9c90a5 100644 --- a/golem_resource_report/__manifest__.py +++ b/golem_resource_report/__manifest__.py @@ -28,6 +28,7 @@ 'installable': True, 'depends': ['golem_resource'], 'data': ['reports/golem_reservation_report.xml', + 'reports/golem_reservation_report_menu.xml', 'views/golem_resource_report_menu.xml', 'wizard/golem_resource_report_wizard_views.xml'] } diff --git a/golem_resource_report/reports/__init__.py b/golem_resource_report/reports/__init__.py new file mode 100644 index 0000000..1c0b8fe --- /dev/null +++ b/golem_resource_report/reports/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import golem_reservation_report diff --git a/golem_resource_report/reports/golem_reservation_report.py b/golem_resource_report/reports/golem_reservation_report.py new file mode 100644 index 0000000..a1858be --- /dev/null +++ b/golem_resource_report/reports/golem_reservation_report.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import time + +from odoo import models, api + + +class GolemResevationReport(models.AbstractModel): + _name = 'report.golem_resource_report.golem_reservation_report' + + def get_total_reservation(self, data): + domain = [('date_start', '>', data['date_start']), + ('date_stop', '<', data['date_stop']), + ('resource_id', 'in', data['resource_ids'])] + return self.env['golem.resource.reservation'].search_count(domain) + + + def get_data(self, data): + lst = [] + domain = [('date_start', '>', data['date_start']), + ('date_stop', '<', data['date_stop']), + ('resource_id', 'in', data['resource_ids'])] + reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') + res = {} + for reservation in reservations: + res = { + 'name': reservation.name, + 'resource_name': reservation.resource_id.name, + 'client': reservation.partner_id.name, + 'date_start': reservation.date_start, + 'date_stop': reservation.date_stop + } + lst.append(res) + + #self.total_student = 0 + """for student in student_search: + self.total_student += 1 + res = { + 'name': student.name, + 'middle_name': student.middle_name, + 'last_name': student.last_name, + 'application_no': student.application_number, + } + lst.append(res)""" + return lst + + @api.model + def render_html(self, docids, data=None): + model = self.env.context.get('active_model') + docs = self.env[model].browse(self.env.context.get('active_id')) + docargs = { + 'doc_ids': self.ids, + 'doc_model': model, + 'docs': docs, + 'time': time, + 'data': data, + 'date_start': data['date_start'], + 'date_stop': data['date_stop'], + 'get_total_reservation': self.get_total_reservation(data), + 'get_data': self.get_data(data), + } + return self.env['report'] \ + .render('golem_resource_report.golem_reservation_report', docargs) diff --git a/golem_resource_report/reports/golem_reservation_report.xml b/golem_resource_report/reports/golem_reservation_report.xml index 71bdca2..60f8da5 100644 --- a/golem_resource_report/reports/golem_reservation_report.xml +++ b/golem_resource_report/reports/golem_reservation_report.xml @@ -1,8 +1,62 @@ - + + - + + + diff --git a/golem_resource_report/reports/golem_reservation_report_menu.xml b/golem_resource_report/reports/golem_reservation_report_menu.xml new file mode 100644 index 0000000..d1090cd --- /dev/null +++ b/golem_resource_report/reports/golem_reservation_report_menu.xml @@ -0,0 +1,49 @@ + + + + + + European A4 Landscape + + A4 + 0 + 0 + Landscape + 10 + 23 + 7 + 7 + + 35 + 90 + + + + diff --git a/golem_resource_report/views/golem_resource_report_menu.xml b/golem_resource_report/views/golem_resource_report_menu.xml index ec823e4..14ba437 100644 --- a/golem_resource_report/views/golem_resource_report_menu.xml +++ b/golem_resource_report/views/golem_resource_report_menu.xml @@ -1,3 +1,21 @@ + + diff --git a/golem_resource_report/wizard/golem_resource_report_wizard.py b/golem_resource_report/wizard/golem_resource_report_wizard.py index cb0dafe..c56a2f3 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard.py +++ b/golem_resource_report/wizard/golem_resource_report_wizard.py @@ -38,7 +38,10 @@ class GolemResourceReportWizard(models.TransientModel): 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) + data = self.read( + ['resource_ids', 'date_start', 'date_stop'])[0] + return self.env['report'].get_action( + self, 'golem_resource_report.golem_reservation_report', + data=data) + + 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 07aa754..1cfbdea 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard_views.xml +++ b/golem_resource_report/wizard/golem_resource_report_wizard_views.xml @@ -18,7 +18,6 @@ along with this program. If not, see . --> - GOLEM resource Report Wizard Form @@ -28,7 +27,7 @@ along with this program. If not, see . - + @@ -45,7 +44,6 @@ along with this program. If not, see . - - + From 94bdd6240a280c9f57aae67b998c18e3245ebc70 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Thu, 12 Apr 2018 18:58:19 +0200 Subject: [PATCH 05/15] =?UTF-8?q?quelques=20am=C3=A9liorations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reports/golem_reservation_report.py | 11 ----------- .../wizard/golem_resource_report_wizard_views.xml | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/golem_resource_report/reports/golem_reservation_report.py b/golem_resource_report/reports/golem_reservation_report.py index a1858be..6867d45 100644 --- a/golem_resource_report/reports/golem_reservation_report.py +++ b/golem_resource_report/reports/golem_reservation_report.py @@ -47,17 +47,6 @@ class GolemResevationReport(models.AbstractModel): 'date_stop': reservation.date_stop } lst.append(res) - - #self.total_student = 0 - """for student in student_search: - self.total_student += 1 - res = { - 'name': student.name, - 'middle_name': student.middle_name, - 'last_name': student.last_name, - 'application_no': student.application_number, - } - lst.append(res)""" return lst @api.model 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 1cfbdea..0d28277 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard_views.xml +++ b/golem_resource_report/wizard/golem_resource_report_wizard_views.xml @@ -26,8 +26,8 @@ along with this program. If not, see .
- - + + From ce325aa0547599a2397924087bde38917a6533ca Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 13 Apr 2018 19:18:59 +0200 Subject: [PATCH 06/15] =?UTF-8?q?Am=C3=A9lioration=20de=20l'affichage=20du?= =?UTF-8?q?=20rappoort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reports/golem_reservation_report.py | 24 ++++++++++++++++++- .../reports/golem_reservation_report.xml | 22 +++++++++-------- .../wizard/golem_resource_report_wizard.py | 12 ++++++++-- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/golem_resource_report/reports/golem_reservation_report.py b/golem_resource_report/reports/golem_reservation_report.py index 6867d45..1e84b7e 100644 --- a/golem_resource_report/reports/golem_reservation_report.py +++ b/golem_resource_report/reports/golem_reservation_report.py @@ -18,9 +18,11 @@ import time +from random import randint from odoo import models, api + class GolemResevationReport(models.AbstractModel): _name = 'report.golem_resource_report.golem_reservation_report' @@ -31,6 +33,23 @@ class GolemResevationReport(models.AbstractModel): return self.env['golem.resource.reservation'].search_count(domain) + + + def get_resource(self, data): + lst = [] + domain = [('date_start', '>', data['date_start']), + ('date_stop', '<', data['date_stop']), + ('resource_id', 'in', data['resource_ids'])] + reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') + lst = reservations.mapped('resource_id.name') + return lst + + def get_client_color(self, client_id): + client_id *= 777777 + color = "#0" + str(client_id) + color = color[:7] + return color + def get_data(self, data): lst = [] domain = [('date_start', '>', data['date_start']), @@ -43,8 +62,10 @@ class GolemResevationReport(models.AbstractModel): 'name': reservation.name, 'resource_name': reservation.resource_id.name, 'client': reservation.partner_id.name, + 'client_id': self.get_client_color(reservation.partner_id.id), 'date_start': reservation.date_start, - 'date_stop': reservation.date_stop + 'date_stop': reservation.date_stop, + 'day_start': reservation.day_start } lst.append(res) return lst @@ -63,6 +84,7 @@ class GolemResevationReport(models.AbstractModel): 'date_stop': data['date_stop'], 'get_total_reservation': self.get_total_reservation(data), 'get_data': self.get_data(data), + 'get_resource': self.get_resource(data), } return self.env['report'] \ .render('golem_resource_report.golem_reservation_report', docargs) diff --git a/golem_resource_report/reports/golem_reservation_report.xml b/golem_resource_report/reports/golem_reservation_report.xml index 60f8da5..9162793 100644 --- a/golem_resource_report/reports/golem_reservation_report.xml +++ b/golem_resource_report/reports/golem_reservation_report.xml @@ -40,16 +40,18 @@ along with this program. If not, see . - - - - + + + + + + + +
- - - - - -
+ Date :
+ On behalf of :
+ client_id :
+
diff --git a/golem_resource_report/wizard/golem_resource_report_wizard.py b/golem_resource_report/wizard/golem_resource_report_wizard.py index c56a2f3..fc38925 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard.py +++ b/golem_resource_report/wizard/golem_resource_report_wizard.py @@ -40,8 +40,16 @@ class GolemResourceReportWizard(models.TransientModel): else: data = self.read( ['resource_ids', 'date_start', 'date_stop'])[0] + + lst = [] + domain = [('date_start', '>', data['date_start']), + ('date_stop', '<', data['date_stop']), + ('resource_id', 'in', data['resource_ids'])] + reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') + lst = reservations.mapped('resource_id.name') + print '____________________________________' + print lst + return self.env['report'].get_action( self, 'golem_resource_report.golem_reservation_report', data=data) - - From 1398cb945d323df47286adbd5f0a085c55a3f7b3 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Mon, 16 Apr 2018 17:10:22 +0200 Subject: [PATCH 07/15] modification couleurs --- .../reports/golem_reservation_report.py | 26 ++++++++++++++----- .../reports/golem_reservation_report.xml | 4 +-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/golem_resource_report/reports/golem_reservation_report.py b/golem_resource_report/reports/golem_reservation_report.py index 1e84b7e..042a10d 100644 --- a/golem_resource_report/reports/golem_reservation_report.py +++ b/golem_resource_report/reports/golem_reservation_report.py @@ -44,10 +44,17 @@ class GolemResevationReport(models.AbstractModel): lst = reservations.mapped('resource_id.name') return lst - def get_client_color(self, client_id): - client_id *= 777777 - color = "#0" + str(client_id) - color = color[:7] + def get_client_color(self, partner_number): + colors = ['#FFFF5B', '#81EC54', '#47C8C8', '#FB5A66', '#E8E750', + '#CF4ACF', '#9655D2', '#FFA15B', '#5F68D5', '#60E652'] + color = "#000000" + if partner_number < 10: + color = colors[partner_number] + else: + red = randint(128, 255) + green = randint(128, 255) + blue = randint(128, 255) + color = "#" +hex(red)[2:]+hex(green)[2:]+hex(blue)[2:] return color def get_data(self, data): @@ -56,16 +63,23 @@ class GolemResevationReport(models.AbstractModel): ('date_stop', '<', data['date_stop']), ('resource_id', 'in', data['resource_ids'])] reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') + partner_ids = reservations.mapped('partner_id.id') + partner_colors = {} + partner_number = 0 + for partner_id in partner_ids: + partner_colors[str(partner_id)] = self.get_client_color(partner_number) + partner_number +=1 + res = {} for reservation in reservations: res = { 'name': reservation.name, 'resource_name': reservation.resource_id.name, 'client': reservation.partner_id.name, - 'client_id': self.get_client_color(reservation.partner_id.id), 'date_start': reservation.date_start, 'date_stop': reservation.date_stop, - 'day_start': reservation.day_start + 'day_start': reservation.day_start, + 'bgcolor': partner_colors[str(reservation.partner_id.id)] } lst.append(res) return lst diff --git a/golem_resource_report/reports/golem_reservation_report.xml b/golem_resource_report/reports/golem_reservation_report.xml index 9162793..b545aff 100644 --- a/golem_resource_report/reports/golem_reservation_report.xml +++ b/golem_resource_report/reports/golem_reservation_report.xml @@ -45,10 +45,10 @@ along with this program. If not, see . - + Date :
On behalf of :
- client_id :
+ client_id :
From e7464a62b305464d352169abf118336bfaaf00d9 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Mon, 16 Apr 2018 17:48:14 +0200 Subject: [PATCH 08/15] code refactoring --- .../reports/golem_reservation_report.py | 13 ++++++++----- .../reports/golem_reservation_report.xml | 2 -- .../wizard/golem_resource_report_wizard.py | 15 +++------------ 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/golem_resource_report/reports/golem_reservation_report.py b/golem_resource_report/reports/golem_reservation_report.py index 042a10d..d482e8a 100644 --- a/golem_resource_report/reports/golem_reservation_report.py +++ b/golem_resource_report/reports/golem_reservation_report.py @@ -15,7 +15,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - +""" Golem Reservation Report """ import time from random import randint @@ -24,18 +24,18 @@ from odoo import models, api class GolemResevationReport(models.AbstractModel): + "Golem Reservation Report" _name = 'report.golem_resource_report.golem_reservation_report' def get_total_reservation(self, data): + "Get Reservation Count" domain = [('date_start', '>', data['date_start']), ('date_stop', '<', data['date_stop']), ('resource_id', 'in', data['resource_ids'])] return self.env['golem.resource.reservation'].search_count(domain) - - - def get_resource(self, data): + "Get Resource List" lst = [] domain = [('date_start', '>', data['date_start']), ('date_stop', '<', data['date_stop']), @@ -45,6 +45,7 @@ class GolemResevationReport(models.AbstractModel): return lst def get_client_color(self, partner_number): + "Get Client Color" colors = ['#FFFF5B', '#81EC54', '#47C8C8', '#FB5A66', '#E8E750', '#CF4ACF', '#9655D2', '#FFA15B', '#5F68D5', '#60E652'] color = "#000000" @@ -58,6 +59,7 @@ class GolemResevationReport(models.AbstractModel): return color def get_data(self, data): + "Get Resevation Data" lst = [] domain = [('date_start', '>', data['date_start']), ('date_stop', '<', data['date_stop']), @@ -68,7 +70,7 @@ class GolemResevationReport(models.AbstractModel): partner_number = 0 for partner_id in partner_ids: partner_colors[str(partner_id)] = self.get_client_color(partner_number) - partner_number +=1 + partner_number += 1 res = {} for reservation in reservations: @@ -86,6 +88,7 @@ class GolemResevationReport(models.AbstractModel): @api.model def render_html(self, docids, data=None): + "Render HTML" model = self.env.context.get('active_model') docs = self.env[model].browse(self.env.context.get('active_id')) docargs = { diff --git a/golem_resource_report/reports/golem_reservation_report.xml b/golem_resource_report/reports/golem_reservation_report.xml index b545aff..0df78a7 100644 --- a/golem_resource_report/reports/golem_reservation_report.xml +++ b/golem_resource_report/reports/golem_reservation_report.xml @@ -40,7 +40,6 @@ along with this program. If not, see . - @@ -48,7 +47,6 @@ along with this program. If not, see . diff --git a/golem_resource_report/wizard/golem_resource_report_wizard.py b/golem_resource_report/wizard/golem_resource_report_wizard.py index fc38925..684c41d 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard.py +++ b/golem_resource_report/wizard/golem_resource_report_wizard.py @@ -16,13 +16,13 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -""" GOLEM Resources management """ +""" GOLEM Resources Report Wizard """ from odoo import models, fields, api, _ from odoo.exceptions import ValidationError class GolemResourceReportWizard(models.TransientModel): - """GOLEM Resource wizard : refusal reason for a reservation """ + """GOLEM Report Wizard : Choose report parameters """ _name = "golem.resource.report.wizard" resource_ids = fields.Many2many('golem.resource') @@ -31,6 +31,7 @@ class GolemResourceReportWizard(models.TransientModel): @api.multi def print_report(self): + """ Print Report """ for record in self: start_date = fields.Datetime.from_string(record.date_start) stop_date = fields.Datetime.from_string(record.date_stop) @@ -40,16 +41,6 @@ class GolemResourceReportWizard(models.TransientModel): else: data = self.read( ['resource_ids', 'date_start', 'date_stop'])[0] - - lst = [] - domain = [('date_start', '>', data['date_start']), - ('date_stop', '<', data['date_stop']), - ('resource_id', 'in', data['resource_ids'])] - reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') - lst = reservations.mapped('resource_id.name') - print '____________________________________' - print lst - return self.env['report'].get_action( self, 'golem_resource_report.golem_reservation_report', data=data) From 704e2809c2fea76e960cb563c3b5d550eb8fb4cf Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 25 May 2018 09:56:48 +0200 Subject: [PATCH 09/15] [FIX]GOLEM Resource Report : bad data ordering when installing --- golem_resource_report/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/golem_resource_report/__manifest__.py b/golem_resource_report/__manifest__.py index d9c90a5..4f65daa 100644 --- a/golem_resource_report/__manifest__.py +++ b/golem_resource_report/__manifest__.py @@ -29,6 +29,6 @@ 'depends': ['golem_resource'], 'data': ['reports/golem_reservation_report.xml', 'reports/golem_reservation_report_menu.xml', - 'views/golem_resource_report_menu.xml', - 'wizard/golem_resource_report_wizard_views.xml'] + 'wizard/golem_resource_report_wizard_views.xml', + 'views/golem_resource_report_menu.xml'] } From 66a46d65f6883f7c93b40d52fc9cebc3faa5f33c Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 25 May 2018 11:42:48 +0200 Subject: [PATCH 10/15] [REF]GOLEM Resource Report : global refactoring --- golem_resource_report/__init__.py | 4 +- golem_resource_report/__manifest__.py | 7 +- .../data/golem_resource_report_data.xml | 40 +++++++++ .../reports/golem_reservation_report.py | 77 +++++++---------- .../reports/golem_reservation_report.xml | 86 ++++++++++--------- .../reports/golem_reservation_report_menu.xml | 39 +++------ .../views/golem_resource_report_menu.xml | 22 ++--- .../wizard/golem_resource_report_wizard.py | 26 +++--- .../golem_resource_report_wizard_views.xml | 8 +- 9 files changed, 161 insertions(+), 148 deletions(-) create mode 100644 golem_resource_report/data/golem_resource_report_data.xml diff --git a/golem_resource_report/__init__.py b/golem_resource_report/__init__.py index f1d4cf2..d766ae4 100644 --- a/golem_resource_report/__init__.py +++ b/golem_resource_report/__init__.py @@ -16,6 +16,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -#from . import models -from . import wizard -from . import reports +from . import reports, wizard diff --git a/golem_resource_report/__manifest__.py b/golem_resource_report/__manifest__.py index 4f65daa..8b40f73 100644 --- a/golem_resource_report/__manifest__.py +++ b/golem_resource_report/__manifest__.py @@ -20,14 +20,15 @@ 'name': 'GOLEM resources reports', 'summary': 'GOLEM resources reports', 'description': ''' GOLEM resources reports ''', - 'version': '10.0.0.0.0', + 'version': '10.0.0.1.0', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', - 'application': True, + 'application': False, 'installable': True, 'depends': ['golem_resource'], - 'data': ['reports/golem_reservation_report.xml', + 'data': ['data/golem_resource_report_data.xml', + 'reports/golem_reservation_report.xml', 'reports/golem_reservation_report_menu.xml', 'wizard/golem_resource_report_wizard_views.xml', 'views/golem_resource_report_menu.xml'] diff --git a/golem_resource_report/data/golem_resource_report_data.xml b/golem_resource_report/data/golem_resource_report_data.xml new file mode 100644 index 0000000..2f00f40 --- /dev/null +++ b/golem_resource_report/data/golem_resource_report_data.xml @@ -0,0 +1,40 @@ + + + + + + + European A4 Landscape + + A4 + 0 + 0 + Landscape + 10 + 23 + 7 + 7 + + 35 + 90 + + + + diff --git a/golem_resource_report/reports/golem_reservation_report.py b/golem_resource_report/reports/golem_reservation_report.py index d482e8a..8e94b7a 100644 --- a/golem_resource_report/reports/golem_reservation_report.py +++ b/golem_resource_report/reports/golem_reservation_report.py @@ -15,66 +15,52 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -""" Golem Reservation Report """ -import time +""" Golem Reservation Report """ + +import time from random import randint from odoo import models, api +def get_client_color(partner_number): + """ Get Client Color """ + colors = ['#FFFF5B', '#81EC54', '#47C8C8', '#FB5A66', '#E8E750', + '#CF4ACF', '#9655D2', '#FFA15B', '#5F68D5', '#60E652'] + color = "#000000" + if partner_number < 10: + color = colors[partner_number] + else: + red = randint(128, 255) + green = randint(128, 255) + blue = randint(128, 255) + color = "#" +hex(red)[2:]+hex(green)[2:]+hex(blue)[2:] + return color class GolemResevationReport(models.AbstractModel): - "Golem Reservation Report" + """ Golem Reservation Report """ _name = 'report.golem_resource_report.golem_reservation_report' - - def get_total_reservation(self, data): - "Get Reservation Count" - domain = [('date_start', '>', data['date_start']), - ('date_stop', '<', data['date_stop']), - ('resource_id', 'in', data['resource_ids'])] - return self.env['golem.resource.reservation'].search_count(domain) - - def get_resource(self, data): - "Get Resource List" - lst = [] - domain = [('date_start', '>', data['date_start']), - ('date_stop', '<', data['date_stop']), - ('resource_id', 'in', data['resource_ids'])] - reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') - lst = reservations.mapped('resource_id.name') - return lst - - def get_client_color(self, partner_number): - "Get Client Color" - colors = ['#FFFF5B', '#81EC54', '#47C8C8', '#FB5A66', '#E8E750', - '#CF4ACF', '#9655D2', '#FFA15B', '#5F68D5', '#60E652'] - color = "#000000" - if partner_number < 10: - color = colors[partner_number] - else: - red = randint(128, 255) - green = randint(128, 255) - blue = randint(128, 255) - color = "#" +hex(red)[2:]+hex(green)[2:]+hex(blue)[2:] - return color + _description = 'Golem Reservation Report' def get_data(self, data): - "Get Resevation Data" - lst = [] + """ Get Resevation Data """ + res = [] domain = [('date_start', '>', data['date_start']), ('date_stop', '<', data['date_stop']), ('resource_id', 'in', data['resource_ids'])] reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') + total_reservations = len(reservations) + resources = list(reservations.mapped('resource_id.name')) + partner_ids = reservations.mapped('partner_id.id') partner_colors = {} partner_number = 0 for partner_id in partner_ids: - partner_colors[str(partner_id)] = self.get_client_color(partner_number) + partner_colors[str(partner_id)] = get_client_color(partner_number) partner_number += 1 - res = {} for reservation in reservations: - res = { + line = { 'name': reservation.name, 'resource_name': reservation.resource_id.name, 'client': reservation.partner_id.name, @@ -83,14 +69,15 @@ class GolemResevationReport(models.AbstractModel): 'day_start': reservation.day_start, 'bgcolor': partner_colors[str(reservation.partner_id.id)] } - lst.append(res) - return lst + res.append(line) + return res, total_reservations, resources @api.model def render_html(self, docids, data=None): - "Render HTML" + """ Render HTML """ model = self.env.context.get('active_model') docs = self.env[model].browse(self.env.context.get('active_id')) + _data, total_reservations, resources = self.get_data(data) docargs = { 'doc_ids': self.ids, 'doc_model': model, @@ -99,9 +86,9 @@ class GolemResevationReport(models.AbstractModel): 'data': data, 'date_start': data['date_start'], 'date_stop': data['date_stop'], - 'get_total_reservation': self.get_total_reservation(data), - 'get_data': self.get_data(data), - 'get_resource': self.get_resource(data), + 'get_total_reservation': total_reservations, + 'get_data': _data, + 'get_resource': resources } return self.env['report'] \ .render('golem_resource_report.golem_reservation_report', docargs) diff --git a/golem_resource_report/reports/golem_reservation_report.xml b/golem_resource_report/reports/golem_reservation_report.xml index 0df78a7..e824b9f 100644 --- a/golem_resource_report/reports/golem_reservation_report.xml +++ b/golem_resource_report/reports/golem_reservation_report.xml @@ -17,46 +17,48 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> - - - + + + + + diff --git a/golem_resource_report/reports/golem_reservation_report_menu.xml b/golem_resource_report/reports/golem_reservation_report_menu.xml index d1090cd..5ef6c1d 100644 --- a/golem_resource_report/reports/golem_reservation_report_menu.xml +++ b/golem_resource_report/reports/golem_reservation_report_menu.xml @@ -18,32 +18,15 @@ along with this program. If not, see . --> - - European A4 Landscape - - A4 - 0 - 0 - Landscape - 10 - 23 - 7 - 7 - - 35 - 90 - - - + + + + diff --git a/golem_resource_report/views/golem_resource_report_menu.xml b/golem_resource_report/views/golem_resource_report_menu.xml index 14ba437..a75dc9a 100644 --- a/golem_resource_report/views/golem_resource_report_menu.xml +++ b/golem_resource_report/views/golem_resource_report_menu.xml @@ -20,19 +20,19 @@ along with this program. If not, see . - - Resources Reports - golem.resource.report.wizard - form - form - - {} - new - + + 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 684c41d..fd6a41e 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard.py +++ b/golem_resource_report/wizard/golem_resource_report_wizard.py @@ -30,17 +30,17 @@ class GolemResourceReportWizard(models.TransientModel): date_stop = fields.Datetime(required=True) @api.multi - def print_report(self): + def print_resource_report(self): """ Print Report """ - for record in self: - 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: - data = self.read( - ['resource_ids', 'date_start', 'date_stop'])[0] - return self.env['report'].get_action( - self, 'golem_resource_report.golem_reservation_report', - data=data) + self.ensure_one() + record = self[0] + 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: + data = self.read( + ['resource_ids', 'date_start', 'date_stop'])[0] + return self.env['report'].get_action( + self, 'golem_resource_report.golem_reservation_report', + data=data) 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 0d28277..af23086 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard_views.xml +++ b/golem_resource_report/wizard/golem_resource_report_wizard_views.xml @@ -18,6 +18,7 @@ along with this program. If not, see . --> + GOLEM resource Report Wizard Form @@ -27,7 +28,7 @@ along with this program. If not, see . - + @@ -38,12 +39,13 @@ along with this program. If not, see .
-
+
From 654d2de6b4240c68c1ab1e318bbee11db0f9c798 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 25 May 2018 16:32:44 +0200 Subject: [PATCH 11/15] [REF][IMP]GOLEM Resource Report : huge refactoring of report model and data with representation per date, then, resource, then dates, then periods --- .../reports/golem_reservation_report.py | 39 +++++++---- .../reports/golem_reservation_report.xml | 64 ++++++++++++------- .../wizard/golem_resource_report_wizard.py | 8 +-- 3 files changed, 69 insertions(+), 42 deletions(-) diff --git a/golem_resource_report/reports/golem_reservation_report.py b/golem_resource_report/reports/golem_reservation_report.py index 8e94b7a..3faa007 100644 --- a/golem_resource_report/reports/golem_reservation_report.py +++ b/golem_resource_report/reports/golem_reservation_report.py @@ -20,7 +20,9 @@ import time from random import randint -from odoo import models, api +from odoo import models, fields, api + +# FIXME: usage of Odoo fields will be needed for i18n awareness def get_client_color(partner_number): """ Get Client Color """ @@ -44,13 +46,13 @@ class GolemResevationReport(models.AbstractModel): def get_data(self, data): """ Get Resevation Data """ - res = [] domain = [('date_start', '>', data['date_start']), ('date_stop', '<', data['date_stop']), ('resource_id', 'in', data['resource_ids'])] reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') total_reservations = len(reservations) - resources = list(reservations.mapped('resource_id.name')) + resources = {r.resource_id.id: r.resource_id.name for r in reservations} + days = sorted(list(set(reservations.mapped('day_start')))) partner_ids = reservations.mapped('partner_id.id') partner_colors = {} @@ -59,36 +61,47 @@ class GolemResevationReport(models.AbstractModel): partner_colors[str(partner_id)] = get_client_color(partner_number) partner_number += 1 + res = {} # List of multi-levels : group by resource, then, day_start for reservation in reservations: + resource = reservation.resource_id.id + day_start = reservation.day_start + if not resource in res: + res[resource] = {} + if not day_start in res[resource]: + res[resource][day_start] = [] line = { 'name': reservation.name, 'resource_name': reservation.resource_id.name, - 'client': reservation.partner_id.name, + 'partner': reservation.partner_id.name, 'date_start': reservation.date_start, 'date_stop': reservation.date_stop, 'day_start': reservation.day_start, - 'bgcolor': partner_colors[str(reservation.partner_id.id)] + 'day_stop': fields.Datetime.from_string(reservation.date_stop).strftime('%Y-%m-%d'), + 'bgcolor': partner_colors[str(reservation.partner_id.id)], + 'note': reservation.note } - res.append(line) - return res, total_reservations, resources + res[resource][day_start].append(line) + return res, total_reservations, resources, days @api.model def render_html(self, docids, data=None): """ Render HTML """ model = self.env.context.get('active_model') docs = self.env[model].browse(self.env.context.get('active_id')) - _data, total_reservations, resources = self.get_data(data) + _data, total_reservations, resources, days = self.get_data(data) docargs = { 'doc_ids': self.ids, 'doc_model': model, 'docs': docs, + 'company': self.env.ref('base.main_company'), 'time': time, 'data': data, - 'date_start': data['date_start'], - 'date_stop': data['date_stop'], - 'get_total_reservation': total_reservations, - 'get_data': _data, - 'get_resource': resources + 'date_start': '%s 00:00:00' % data['date_start'], + 'date_stop': '%s 23:59:59' % data['date_stop'], + 'total_reservations': total_reservations, + 'datas': _data, + 'resources': resources, + 'days': days } return self.env['report'] \ .render('golem_resource_report.golem_reservation_report', docargs) diff --git a/golem_resource_report/reports/golem_reservation_report.xml b/golem_resource_report/reports/golem_reservation_report.xml index e824b9f..1b09f3d 100644 --- a/golem_resource_report/reports/golem_reservation_report.xml +++ b/golem_resource_report/reports/golem_reservation_report.xml @@ -24,32 +24,48 @@ along with this program. If not, see .
-

-
Date :
On behalf of :
- client_id :
- - - +

+ : reservations
+ + From Date: + + To Date: + + +

+
-
Maison Phare toutes les reservations
- From Date: - - - To Date: -
-
+ + + + + - -
+
- + - - - - - - + + + + diff --git a/golem_resource_report/wizard/golem_resource_report_wizard.py b/golem_resource_report/wizard/golem_resource_report_wizard.py index fd6a41e..aa89300 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard.py +++ b/golem_resource_report/wizard/golem_resource_report_wizard.py @@ -26,17 +26,15 @@ class GolemResourceReportWizard(models.TransientModel): _name = "golem.resource.report.wizard" resource_ids = fields.Many2many('golem.resource') - date_start = fields.Datetime(required=True) - date_stop = fields.Datetime(required=True) + date_start = fields.Date(required=True) + date_stop = fields.Date(required=True) @api.multi def print_resource_report(self): """ Print Report """ self.ensure_one() record = self[0] - start_date = fields.Datetime.from_string(record.date_start) - stop_date = fields.Datetime.from_string(record.date_stop) - if start_date > stop_date: + if record.date_start > record.date_stop: raise ValidationError(_('Stop Date cannot be set before Start Date.')) else: data = self.read( From ff8a4df86a055f5e7753dec8425c7cee638f4185 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 25 May 2018 16:47:16 +0200 Subject: [PATCH 12/15] [FIX]GOLEM Resource Report : only validated resource should be printed --- golem_resource_report/reports/golem_reservation_report.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/golem_resource_report/reports/golem_reservation_report.py b/golem_resource_report/reports/golem_reservation_report.py index 3faa007..8540a86 100644 --- a/golem_resource_report/reports/golem_reservation_report.py +++ b/golem_resource_report/reports/golem_reservation_report.py @@ -46,7 +46,8 @@ class GolemResevationReport(models.AbstractModel): def get_data(self, data): """ Get Resevation Data """ - domain = [('date_start', '>', data['date_start']), + domain = [('state', '=', 'validated'), + ('date_start', '>', data['date_start']), ('date_stop', '<', data['date_stop']), ('resource_id', 'in', data['resource_ids'])] reservations = self.env['golem.resource.reservation'].search(domain, order='date_start') From b820207d678ff1925db291970447ba901b91bcce Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 25 May 2018 16:56:02 +0200 Subject: [PATCH 13/15] [I18N]GOLEM Resource Report : translations --- golem_resource_report/i18n/fr.po | 147 ++++++++++++++++++ .../i18n/golem_resource_report.pot | 147 ++++++++++++++++++ 2 files changed, 294 insertions(+) create mode 100644 golem_resource_report/i18n/fr.po create mode 100644 golem_resource_report/i18n/golem_resource_report.pot diff --git a/golem_resource_report/i18n/fr.po b/golem_resource_report/i18n/fr.po new file mode 100644 index 0000000..11c23b8 --- /dev/null +++ b/golem_resource_report/i18n/fr.po @@ -0,0 +1,147 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * golem_resource_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-05-25 14:50+0000\n" +"PO-Revision-Date: 2018-05-25 14:50+0000\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: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "
\n" +" To" +msgstr "
\n" +" À" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "From Date: " +msgstr "De : " + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "To Date:" +msgstr "À :" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form +msgid "Close" +msgstr "Fermer" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_create_date +msgid "Created on" +msgstr "Créé le" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_date_start +msgid "Date start" +msgstr "Date de début" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_date_stop +msgid "Date stop" +msgstr "Date de fin" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_display_name +#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report_display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "For" +msgstr "Pour" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "From" +msgstr "De" + +#. module: golem_resource_report +#: model:ir.model,name:golem_resource_report.model_report_golem_resource_report_golem_reservation_report +msgid "Golem Reservation Report" +msgstr "Golem Reservation Report" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_id +#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report_id +msgid "ID" +msgstr "ID" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard___last_update +#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report___last_update +msgid "Last Modified on" +msgstr "Dernière Modification le" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form +msgid "Print Report" +msgstr "Imprimer le rapport" + +#. module: golem_resource_report +#: model:ir.ui.menu,name:golem_resource_report.resource_report_menu +msgid "Report" +msgstr "Rapport" + +#. module: golem_resource_report +#: model:ir.actions.report.xml,name:golem_resource_report.action_report_report_admission_analysis +msgid "Reservations Report" +msgstr "Export réservations" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form +msgid "Resource Report" +msgstr "Ressource" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_resource_ids +msgid "Resource ids" +msgstr "Resources" + +#. module: golem_resource_report +#: model:ir.actions.act_window,name:golem_resource_report.golem_resource_report_action +msgid "Resources Reports" +msgstr "Ressources" + +#. module: golem_resource_report +#: code:addons/golem_resource_report/wizard/golem_resource_report_wizard.py:38 +#, python-format +msgid "Stop Date cannot be set before Start Date." +msgstr "La date de fin ne peut pas être antérieure à celle de début." + +#. module: golem_resource_report +#: model:ir.model,name:golem_resource_report.model_golem_resource_report_wizard +msgid "golem.resource.report.wizard" +msgstr "golem.resource.report.wizard" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "reservations
" +msgstr "réservations
" diff --git a/golem_resource_report/i18n/golem_resource_report.pot b/golem_resource_report/i18n/golem_resource_report.pot new file mode 100644 index 0000000..2d7477b --- /dev/null +++ b/golem_resource_report/i18n/golem_resource_report.pot @@ -0,0 +1,147 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * golem_resource_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-05-25 14:50+0000\n" +"PO-Revision-Date: 2018-05-25 14:50+0000\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: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "
\n" +" To" +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "From Date: " +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "To Date:" +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form +msgid "Close" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_create_uid +msgid "Created by" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_create_date +msgid "Created on" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_date_start +msgid "Date start" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_date_stop +msgid "Date stop" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_display_name +#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report_display_name +msgid "Display Name" +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "For" +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "From" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model,name:golem_resource_report.model_report_golem_resource_report_golem_reservation_report +msgid "Golem Reservation Report" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_id +#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report_id +msgid "ID" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard___last_update +#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report___last_update +msgid "Last Modified on" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_write_date +msgid "Last Updated on" +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form +msgid "Print Report" +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.menu,name:golem_resource_report.resource_report_menu +msgid "Report" +msgstr "" + +#. module: golem_resource_report +#: model:ir.actions.report.xml,name:golem_resource_report.action_report_report_admission_analysis +msgid "Reservations Report" +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form +msgid "Resource Report" +msgstr "" + +#. module: golem_resource_report +#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_resource_ids +msgid "Resource ids" +msgstr "" + +#. module: golem_resource_report +#: model:ir.actions.act_window,name:golem_resource_report.golem_resource_report_action +msgid "Resources Reports" +msgstr "" + +#. module: golem_resource_report +#: code:addons/golem_resource_report/wizard/golem_resource_report_wizard.py:38 +#, python-format +msgid "Stop Date cannot be set before Start Date." +msgstr "" + +#. module: golem_resource_report +#: model:ir.model,name:golem_resource_report.model_golem_resource_report_wizard +msgid "golem.resource.report.wizard" +msgstr "" + +#. module: golem_resource_report +#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report +msgid "reservations
" +msgstr "" + From 41633d574f210c8971c54231f8ef2875951e00a0 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 25 May 2018 17:16:19 +0200 Subject: [PATCH 14/15] [FIX]GOLEM Resource Report : at least 1 resource is needed --- golem_resource_report/wizard/golem_resource_report_wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/golem_resource_report/wizard/golem_resource_report_wizard.py b/golem_resource_report/wizard/golem_resource_report_wizard.py index aa89300..338118f 100644 --- a/golem_resource_report/wizard/golem_resource_report_wizard.py +++ b/golem_resource_report/wizard/golem_resource_report_wizard.py @@ -25,7 +25,7 @@ class GolemResourceReportWizard(models.TransientModel): """GOLEM Report Wizard : Choose report parameters """ _name = "golem.resource.report.wizard" - resource_ids = fields.Many2many('golem.resource') + resource_ids = fields.Many2many('golem.resource', required=True) date_start = fields.Date(required=True) date_stop = fields.Date(required=True) From 1a66cbd81c3f437c3844d604bd875c8ad741e785 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 25 May 2018 17:41:27 +0200 Subject: [PATCH 15/15] [IMP]GOLEM Resource Account : better coherence for quantities and UoM, using XMLIDS --- golem_resource_account/__manifest__.py | 2 +- .../models/golem_resource_reservation.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/golem_resource_account/__manifest__.py b/golem_resource_account/__manifest__.py index 3560e1b..50e5cfb 100644 --- a/golem_resource_account/__manifest__.py +++ b/golem_resource_account/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM resources invoicing', 'summary': 'GOLEM resources invoicing', 'description': ''' GOLEM resources invoicing ''', - 'version': '10.0.0.2.0', + 'version': '10.0.0.3.0', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 94b35ac..ed92997 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -75,11 +75,13 @@ class GolemResourceReservation(models.Model): product.categ_id.property_account_income_categ_id.id delta = fields.Datetime.from_string(reservation.date_stop) - \ fields.Datetime.from_string(reservation.date_start) - quantity = 1 - if product.uom_id.name == 'Hour(s)' or product.uom_id.name == 'Unit(s)': - quantity = int((delta.days * 24) + (delta.seconds/3600.0)) - elif product.uom_id.name == 'Day(s)': - quantity = int(delta.days + (delta.seconds/86400.0))#number of seconds in a day + quantity = 1.0 + # Make quantity coherent with UoM + if product.uom_id in (self.env.ref('product.product_uom_hour'), + self.env.ref('product.product_uom_unit')): + quantity = int(round((delta.days * 24.0) + (delta.seconds/3600.0))) + elif product.uom_id == self.env.ref('product.product_uom_day'): + quantity = int(round(delta.days + (delta.seconds/86400.0))) line_id = self.env['account.invoice.line'].create({ 'invoice_id': invoice_id.id, 'name': product.name,
- Date :
- On behalf of :
-
+ + + +
+ + - + + + + From
+ To +
+

+
+ For +

+
+
+