From e36c9b537cced9c25042e3c46c9141fc98879498 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 28 Mar 2018 16:57:56 +0200 Subject: [PATCH 01/50] =?UTF-8?q?Cr=C3=A9ation=20du=20module=20resource=20?= =?UTF-8?q?pack=20basique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golem_resource_pack/__init__.py | 19 ++ golem_resource_pack/__manifest__.py | 31 ++++ golem_resource_pack/models/__init__.py | 19 ++ .../models/golem_resource_pack.py | 30 ++++ .../views/golem_resource_pack_views.xml | 166 ++++++++++++++++++ 5 files changed, 265 insertions(+) create mode 100644 golem_resource_pack/__init__.py create mode 100644 golem_resource_pack/__manifest__.py create mode 100644 golem_resource_pack/models/__init__.py create mode 100644 golem_resource_pack/models/golem_resource_pack.py create mode 100644 golem_resource_pack/views/golem_resource_pack_views.xml diff --git a/golem_resource_pack/__init__.py b/golem_resource_pack/__init__.py new file mode 100644 index 0000000..1fced20 --- /dev/null +++ b/golem_resource_pack/__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 models diff --git a/golem_resource_pack/__manifest__.py b/golem_resource_pack/__manifest__.py new file mode 100644 index 0000000..1d76008 --- /dev/null +++ b/golem_resource_pack/__manifest__.py @@ -0,0 +1,31 @@ +# -*- 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 pack', + 'summary': 'GOLEM resources pack', + 'description': ''' GOLEM resources pack ''', + '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': ['views/golem_resource_pack_views.xml'] +} diff --git a/golem_resource_pack/models/__init__.py b/golem_resource_pack/models/__init__.py new file mode 100644 index 0000000..35a9273 --- /dev/null +++ b/golem_resource_pack/models/__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_pack diff --git a/golem_resource_pack/models/golem_resource_pack.py b/golem_resource_pack/models/golem_resource_pack.py new file mode 100644 index 0000000..4fdc9ba --- /dev/null +++ b/golem_resource_pack/models/golem_resource_pack.py @@ -0,0 +1,30 @@ +# -*- 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 Resource Packs """ + +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class GolemResourcePack(models.Model): + """ GOLEM Resource Pack Model """ + _name = 'golem.resource.pack' + _description = 'GOLEM Resource Pack Model' + + name = fields.Char()#compute='_compute_name', store=True) diff --git a/golem_resource_pack/views/golem_resource_pack_views.xml b/golem_resource_pack/views/golem_resource_pack_views.xml new file mode 100644 index 0000000..465a589 --- /dev/null +++ b/golem_resource_pack/views/golem_resource_pack_views.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + From 24d08c0774bd19b1c2be16b76378d77c14007b06 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 28 Mar 2018 18:03:17 +0200 Subject: [PATCH 02/50] Ajout des champs et design views --- golem_resource_pack/__manifest__.py | 2 +- golem_resource_pack/models/__init__.py | 3 +- .../models/golem_resource_pack.py | 8 +++ .../models/golem_resource_reservation.py | 31 ++++++++++ .../views/golem_resource_pack_views.xml | 60 +++++++------------ 5 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 golem_resource_pack/models/golem_resource_reservation.py diff --git a/golem_resource_pack/__manifest__.py b/golem_resource_pack/__manifest__.py index 1d76008..1d5a6e6 100644 --- a/golem_resource_pack/__manifest__.py +++ b/golem_resource_pack/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM resources pack', 'summary': 'GOLEM resources pack', 'description': ''' GOLEM resources pack ''', - 'version': '10.0.0.0.0', + 'version': '10.0.0.0.1', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_resource_pack/models/__init__.py b/golem_resource_pack/models/__init__.py index 35a9273..ea2f68b 100644 --- a/golem_resource_pack/models/__init__.py +++ b/golem_resource_pack/models/__init__.py @@ -16,4 +16,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import golem_resource_pack +from . import golem_resource_pack, \ + golem_resource_reservation diff --git a/golem_resource_pack/models/golem_resource_pack.py b/golem_resource_pack/models/golem_resource_pack.py index 4fdc9ba..028c7af 100644 --- a/golem_resource_pack/models/golem_resource_pack.py +++ b/golem_resource_pack/models/golem_resource_pack.py @@ -28,3 +28,11 @@ class GolemResourcePack(models.Model): _description = 'GOLEM Resource Pack Model' name = fields.Char()#compute='_compute_name', store=True) + reservation_ids = fields.One2many('golem.resource.reservation', 'pack_id') + + note = fields.Text(help='Notes, optional subject for the reservation, reason') + + user_id = fields.Many2one('res.users', required=True, index=True, readonly=True, + string='User', default=lambda self: self.env.user) + partner_id = fields.Many2one('res.partner', string='On behalf of', + required=True, index=True) diff --git a/golem_resource_pack/models/golem_resource_reservation.py b/golem_resource_pack/models/golem_resource_reservation.py new file mode 100644 index 0000000..bf4c7c6 --- /dev/null +++ b/golem_resource_pack/models/golem_resource_reservation.py @@ -0,0 +1,31 @@ +# -*- 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 Resource Reservation """ + +from math import modf +from datetime import timedelta +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class GolemResourceReservation(models.Model): + """ GOLEM Resource Reservation Model """ + _inherit = 'golem.resource.reservation' + + pack_id = fields.Many2one('golem_resource_reservation', 'Reservation Pack') diff --git a/golem_resource_pack/views/golem_resource_pack_views.xml b/golem_resource_pack/views/golem_resource_pack_views.xml index 465a589..6b0b0ad 100644 --- a/golem_resource_pack/views/golem_resource_pack_views.xml +++ b/golem_resource_pack/views/golem_resource_pack_views.xml @@ -35,29 +35,24 @@ along with this program. If not, see . --> - + - - - - - - - - - - - - - - - - - - + + + + + -
+ - --> + + res_model="golem.resource.pack" view_mode="tree,form" /> Date: Thu, 29 Mar 2018 15:05:48 +0200 Subject: [PATCH 03/50] Ajout de fonction de confirmation de pack --- golem_resource_pack/__manifest__.py | 2 +- golem_resource_pack/models/golem_resource_pack.py | 11 +++++++++++ .../views/golem_resource_pack_views.xml | 11 ++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/golem_resource_pack/__manifest__.py b/golem_resource_pack/__manifest__.py index 1d5a6e6..81dd541 100644 --- a/golem_resource_pack/__manifest__.py +++ b/golem_resource_pack/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM resources pack', 'summary': 'GOLEM resources pack', 'description': ''' GOLEM resources pack ''', - 'version': '10.0.0.0.1', + 'version': '10.0.0.0.2', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_resource_pack/models/golem_resource_pack.py b/golem_resource_pack/models/golem_resource_pack.py index 028c7af..ff77af1 100644 --- a/golem_resource_pack/models/golem_resource_pack.py +++ b/golem_resource_pack/models/golem_resource_pack.py @@ -36,3 +36,14 @@ class GolemResourcePack(models.Model): string='User', default=lambda self: self.env.user) partner_id = fields.Many2one('res.partner', string='On behalf of', required=True, index=True) + state = fields.Selection([('canceled', 'Canceled'), + ('draft', 'Draft'), + ('confirmed', 'Confirmed'), + ('validated', 'Validated'), + ('rejected', 'Rejected')], + default='draft') + + @api.multi + def state_confirm(self): + for pack in self: + pack.reservation_ids.state_confirm() diff --git a/golem_resource_pack/views/golem_resource_pack_views.xml b/golem_resource_pack/views/golem_resource_pack_views.xml index 6b0b0ad..526c5a7 100644 --- a/golem_resource_pack/views/golem_resource_pack_views.xml +++ b/golem_resource_pack/views/golem_resource_pack_views.xml @@ -52,10 +52,10 @@ along with this program. If not, see . golem.resource.pack
- - --> + + - + + groups="golem_base.group_golem_manager" /> From 1afbe75845269e2f0bfcc422cbb2ada714142f5b Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 30 Mar 2018 02:10:54 +0200 Subject: [PATCH 05/50] =?UTF-8?q?Ajout=20de=20securit=C3=A9=20et=20coloris?= =?UTF-8?q?ation=20de=20la=20liste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golem_resource_pack/__manifest__.py | 5 +++-- golem_resource_pack/security/ir.model.access.csv | 3 +++ golem_resource_pack/views/golem_resource_pack_views.xml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 golem_resource_pack/security/ir.model.access.csv diff --git a/golem_resource_pack/__manifest__.py b/golem_resource_pack/__manifest__.py index 81dd541..344d218 100644 --- a/golem_resource_pack/__manifest__.py +++ b/golem_resource_pack/__manifest__.py @@ -20,12 +20,13 @@ 'name': 'GOLEM resources pack', 'summary': 'GOLEM resources pack', 'description': ''' GOLEM resources pack ''', - 'version': '10.0.0.0.2', + 'version': '10.0.0.0.3', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', 'application': True, 'installable': True, 'depends': ['golem_resource'], - 'data': ['views/golem_resource_pack_views.xml'] + 'data': ['views/golem_resource_pack_views.xml', + 'security/ir.model.access.csv'] } diff --git a/golem_resource_pack/security/ir.model.access.csv b/golem_resource_pack/security/ir.model.access.csv new file mode 100644 index 0000000..796d31b --- /dev/null +++ b/golem_resource_pack/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_golem_resource_pack_user,Access GOLEM Resource Pack User,model_golem_resource_pack,golem_base.group_golem_user,1,0,0,0 +access_golem_resource_pack_manager,Access GOLEM Resource Pack Manager,model_golem_resource_pack,golem_base.group_golem_manager,1,1,1,1 diff --git a/golem_resource_pack/views/golem_resource_pack_views.xml b/golem_resource_pack/views/golem_resource_pack_views.xml index 52ffcda..dfe9db0 100644 --- a/golem_resource_pack/views/golem_resource_pack_views.xml +++ b/golem_resource_pack/views/golem_resource_pack_views.xml @@ -39,7 +39,7 @@ along with this program. If not, see . GOLEM Resource Pack Tree golem.resource.pack - + From 36058fe1419432c9c9448a271bab7fba4ecccaa4 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 30 Mar 2018 11:49:58 +0200 Subject: [PATCH 06/50] =?UTF-8?q?Cr=C3=A9ation=20de=20module=20pack=5Facco?= =?UTF-8?q?unt=20:=20structure=20de=20mod=C3=A8le=20et=20vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golem_resource_pack_account/__init__.py | 19 ++++++++ golem_resource_pack_account/__manifest__.py | 32 ++++++++++++++ .../models/__init__.py | 19 ++++++++ .../models/golem_resource_pack.py | 44 +++++++++++++++++++ .../models/golem_resource_reservation.py | 31 +++++++++++++ .../security/ir.model.access.csv | 3 ++ .../views/golem_resource_pack_views.xml | 44 +++++++++++++++++++ 7 files changed, 192 insertions(+) create mode 100644 golem_resource_pack_account/__init__.py create mode 100644 golem_resource_pack_account/__manifest__.py create mode 100644 golem_resource_pack_account/models/__init__.py create mode 100644 golem_resource_pack_account/models/golem_resource_pack.py create mode 100644 golem_resource_pack_account/models/golem_resource_reservation.py create mode 100644 golem_resource_pack_account/security/ir.model.access.csv create mode 100644 golem_resource_pack_account/views/golem_resource_pack_views.xml diff --git a/golem_resource_pack_account/__init__.py b/golem_resource_pack_account/__init__.py new file mode 100644 index 0000000..1fced20 --- /dev/null +++ b/golem_resource_pack_account/__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 models diff --git a/golem_resource_pack_account/__manifest__.py b/golem_resource_pack_account/__manifest__.py new file mode 100644 index 0000000..3fc337f --- /dev/null +++ b/golem_resource_pack_account/__manifest__.py @@ -0,0 +1,32 @@ +# -*- 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 pack invoicing', + 'summary': 'GOLEM resources pack invoicing', + 'description': ''' GOLEM resources pack invoicing ''', + 'version': '10.0.0.0.0', + 'category': 'GOLEM', + 'author': 'Youssef El Ouahby, Fabien Bourgeois', + 'license': 'AGPL-3', + 'application': True, + 'installable': True, + 'depends': ['golem_resource_pack', 'account'], + 'data': ['views/golem_resource_pack_views.xml'] + #'security/ir.model.access.csv'] +} diff --git a/golem_resource_pack_account/models/__init__.py b/golem_resource_pack_account/models/__init__.py new file mode 100644 index 0000000..35a9273 --- /dev/null +++ b/golem_resource_pack_account/models/__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_pack diff --git a/golem_resource_pack_account/models/golem_resource_pack.py b/golem_resource_pack_account/models/golem_resource_pack.py new file mode 100644 index 0000000..d6c411c --- /dev/null +++ b/golem_resource_pack_account/models/golem_resource_pack.py @@ -0,0 +1,44 @@ +# -*- 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 Resource Pack Invoicing """ + +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class GolemResourcePack(models.Model): + """ GOLEM Resource Pack invoice extention """ + _inherit = 'golem.resource.pack' + + invoice_id = fields.Many2one('account.invoice', string="Invoice") + + invoice_state = fields.Selection(related='invoice_id.state', store=True, + copy=False) + invoice_amount_total = fields.Monetary(related='invoice_id.amount_total') + currency_id = fields.Many2one(related='invoice_id.currency_id') + + @api.multi + def create_invoice(self): + """ create invoice """ + pass + + @api.multi + def show_invoice(self): + """ show invoice """ + pass diff --git a/golem_resource_pack_account/models/golem_resource_reservation.py b/golem_resource_pack_account/models/golem_resource_reservation.py new file mode 100644 index 0000000..bf4c7c6 --- /dev/null +++ b/golem_resource_pack_account/models/golem_resource_reservation.py @@ -0,0 +1,31 @@ +# -*- 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 Resource Reservation """ + +from math import modf +from datetime import timedelta +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class GolemResourceReservation(models.Model): + """ GOLEM Resource Reservation Model """ + _inherit = 'golem.resource.reservation' + + pack_id = fields.Many2one('golem_resource_reservation', 'Reservation Pack') diff --git a/golem_resource_pack_account/security/ir.model.access.csv b/golem_resource_pack_account/security/ir.model.access.csv new file mode 100644 index 0000000..796d31b --- /dev/null +++ b/golem_resource_pack_account/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_golem_resource_pack_user,Access GOLEM Resource Pack User,model_golem_resource_pack,golem_base.group_golem_user,1,0,0,0 +access_golem_resource_pack_manager,Access GOLEM Resource Pack Manager,model_golem_resource_pack,golem_base.group_golem_manager,1,1,1,1 diff --git a/golem_resource_pack_account/views/golem_resource_pack_views.xml b/golem_resource_pack_account/views/golem_resource_pack_views.xml new file mode 100644 index 0000000..7fc88f3 --- /dev/null +++ b/golem_resource_pack_account/views/golem_resource_pack_views.xml @@ -0,0 +1,44 @@ + + + + + + + GOLEM Resource Pack Account extentionForm + golem.resource.pack + + + + + + + + + + + + + + From fdf556a8d86d49dc7edef12b003435dd0539aad0 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 30 Mar 2018 17:27:40 +0200 Subject: [PATCH 07/50] Fonction de facturation --- golem_resource_pack_account/__manifest__.py | 4 +- .../models/golem_resource_pack.py | 37 +++++++++++++++++-- .../views/golem_resource_pack_views.xml | 16 +++++++- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/golem_resource_pack_account/__manifest__.py b/golem_resource_pack_account/__manifest__.py index 3fc337f..05c4042 100644 --- a/golem_resource_pack_account/__manifest__.py +++ b/golem_resource_pack_account/__manifest__.py @@ -20,13 +20,13 @@ 'name': 'GOLEM resources pack invoicing', 'summary': 'GOLEM resources pack invoicing', 'description': ''' GOLEM resources pack invoicing ''', - 'version': '10.0.0.0.0', + 'version': '10.0.0.0.1', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', 'application': True, 'installable': True, - 'depends': ['golem_resource_pack', 'account'], + 'depends': ['golem_resource_pack', 'golem_resource_account'], 'data': ['views/golem_resource_pack_views.xml'] #'security/ir.model.access.csv'] } diff --git a/golem_resource_pack_account/models/golem_resource_pack.py b/golem_resource_pack_account/models/golem_resource_pack.py index d6c411c..fc80578 100644 --- a/golem_resource_pack_account/models/golem_resource_pack.py +++ b/golem_resource_pack_account/models/golem_resource_pack.py @@ -32,13 +32,42 @@ class GolemResourcePack(models.Model): copy=False) invoice_amount_total = fields.Monetary(related='invoice_id.amount_total') currency_id = fields.Many2one(related='invoice_id.currency_id') + is_products_set = fields.Boolean(compute="compute_is_products_set") + + @api.multi + def compute_is_products_set(self): + for pack in self: + product_list = list(map(lambda x: x.resource_product_id, pack.reservation_ids)) + if len(filter(lambda x: x.id == False, product_list)) > 0: + pack.is_products_set = False + else: + pack.is_products_set = True @api.multi def create_invoice(self): - """ create invoice """ - pass + """ Invoice creation """ + for pack in self: + pack.reservation_ids.check_before_invoicing() + inv_obj = self.env['account.invoice'] + partner_id = pack.partner_id + invoice_id = inv_obj.create({ + 'origin': pack.name, + 'type': 'out_invoice', + 'reference': False, + 'account_id': partner_id.property_account_receivable_id.id, + 'partner_id': partner_id.id + }) + pack.invoice_id = invoice_id.id + pack.reservation_ids.create_invoice_line(invoice_id) @api.multi def show_invoice(self): - """ show invoice """ - pass + """ Redirects to linked invoice """ + self.ensure_one() + pack = self[0] + if pack.invoice_id: + return {'type': 'ir.actions.act_window', + 'res_model': 'account.invoice', + 'res_id': pack.invoice_id.id, + 'view_mode': 'form', + 'view_id': self.env.ref('account.invoice_form').id} diff --git a/golem_resource_pack_account/views/golem_resource_pack_views.xml b/golem_resource_pack_account/views/golem_resource_pack_views.xml index 7fc88f3..6d37fcd 100644 --- a/golem_resource_pack_account/views/golem_resource_pack_views.xml +++ b/golem_resource_pack_account/views/golem_resource_pack_views.xml @@ -18,21 +18,33 @@ along with this program. If not, see . --> + + + GOLEM Resource Pack Account extention Tree + golem.resource.pack + + + + + + + - GOLEM Resource Pack Account extentionForm + GOLEM Resource Pack Account extention Form golem.resource.pack + From 1415b0306fefbe660e6a5bf428ade5fb6089471a Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 30 Mar 2018 19:03:57 +0200 Subject: [PATCH 08/50] =?UTF-8?q?am=C3=A9lioration=20de=20vue=20et=20raiso?= =?UTF-8?q?n=20de=20rejection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golem_resource_pack/__init__.py | 2 +- golem_resource_pack/__manifest__.py | 3 +- .../models/golem_resource_pack.py | 38 +++++++--- .../views/golem_resource_pack_views.xml | 70 ++----------------- golem_resource_pack/wizard/__init__.py | 19 +++++ .../wizard/golem_pack_rejection.py | 38 ++++++++++ .../wizard/golem_pack_rejection_views.xml | 41 +++++++++++ 7 files changed, 133 insertions(+), 78 deletions(-) create mode 100644 golem_resource_pack/wizard/__init__.py create mode 100644 golem_resource_pack/wizard/golem_pack_rejection.py create mode 100644 golem_resource_pack/wizard/golem_pack_rejection_views.xml diff --git a/golem_resource_pack/__init__.py b/golem_resource_pack/__init__.py index 1fced20..f95e908 100644 --- a/golem_resource_pack/__init__.py +++ b/golem_resource_pack/__init__.py @@ -16,4 +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 models, wizard diff --git a/golem_resource_pack/__manifest__.py b/golem_resource_pack/__manifest__.py index 344d218..7bfea4b 100644 --- a/golem_resource_pack/__manifest__.py +++ b/golem_resource_pack/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM resources pack', 'summary': 'GOLEM resources pack', 'description': ''' GOLEM resources pack ''', - 'version': '10.0.0.0.3', + 'version': '10.0.0.0.4', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', @@ -28,5 +28,6 @@ 'installable': True, 'depends': ['golem_resource'], 'data': ['views/golem_resource_pack_views.xml', + 'wizard/golem_pack_rejection_views.xml', 'security/ir.model.access.csv'] } diff --git a/golem_resource_pack/models/golem_resource_pack.py b/golem_resource_pack/models/golem_resource_pack.py index 9a1b0a1..69fda75 100644 --- a/golem_resource_pack/models/golem_resource_pack.py +++ b/golem_resource_pack/models/golem_resource_pack.py @@ -26,25 +26,39 @@ class GolemResourcePack(models.Model): """ GOLEM Resource Pack Model """ _name = 'golem.resource.pack' _description = 'GOLEM Resource Pack Model' + _inherit = 'mail.thread' name = fields.Char(compute='_compute_name', store=True) - reservation_ids = fields.One2many('golem.resource.reservation', 'pack_id') + reservation_ids = fields.One2many('golem.resource.reservation', 'pack_id', + readonly=True, states={'draft': [('readonly', False)]}, + track_visibility='onchange') - - note = fields.Text(help='Notes, optional subject for the reservation, reason') + note = fields.Text(help='Notes, optional subject for the reservation, reason', + readonly=True, states={'draft': [('readonly', False)]}, + track_visibility='onchange') user_id = fields.Many2one('res.users', required=True, index=True, readonly=True, string='User', default=lambda self: self.env.user) partner_id = fields.Many2one('res.partner', string='On behalf of', - required=True, index=True) + required=True, index=True, readonly=True, + states={'draft': [('readonly', False)]}, + track_visibility='onchange') state = fields.Selection([('canceled', 'Canceled'), ('draft', 'Draft'), ('confirmed', 'Confirmed'), ('validated', 'Validated'), ('rejected', 'Rejected')], - default='draft', compute="_compute_pack_state") + default='draft', compute="_compute_pack_state", + track_visibility='onchange') reservation_count = fields.Integer(compute="_compute_reservation_count", string="Reservation count") + rejection_reason = fields.Text(readonly=True, track_visibility='onchange') + + @api.multi + @api.constrains('partner_id') + def set_reservation_partner(self): + for pack in self: + pack.reservation_ids.write({'partner_id': pack.partner_id.id}) @api.multi @api.depends('reservation_ids') @@ -78,11 +92,15 @@ class GolemResourcePack(models.Model): @api.multi def state_rejected(self): - """ pack rejected """ - for pack in self: - for reservation in pack.reservation_ids: - if reservation.state == "confirmed": - reservation.write({'state' :'rejected'}) + """ Wizard call for pack reject """ + self.ensure_one() + pack_id = self[0] + return {'name' : _('Please enter the rejection reason'), + 'type' : 'ir.actions.act_window', + 'res_model' : 'golem.pack.rejection.wizard', + 'context': {'default_pack_id': pack_id.id}, + 'view_mode': 'form', + 'target': 'new'} @api.depends('partner_id') diff --git a/golem_resource_pack/views/golem_resource_pack_views.xml b/golem_resource_pack/views/golem_resource_pack_views.xml index dfe9db0..37d929d 100644 --- a/golem_resource_pack/views/golem_resource_pack_views.xml +++ b/golem_resource_pack/views/golem_resource_pack_views.xml @@ -18,22 +18,6 @@ along with this program. If not, see . --> - - - - GOLEM Resource Pack Tree @@ -76,66 +60,20 @@ along with this program. If not, see . + - +
- - - diff --git a/golem_resource_pack/wizard/__init__.py b/golem_resource_pack/wizard/__init__.py new file mode 100644 index 0000000..6fa8cf7 --- /dev/null +++ b/golem_resource_pack/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_pack_rejection diff --git a/golem_resource_pack/wizard/golem_pack_rejection.py b/golem_resource_pack/wizard/golem_pack_rejection.py new file mode 100644 index 0000000..2dcb6d8 --- /dev/null +++ b/golem_resource_pack/wizard/golem_pack_rejection.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 Pack management """ + +from odoo import models, fields, api + +class GolemReservationRejectionWizard(models.TransientModel): + """GOLEM Resource wizard : refusal reason for a pack """ + _name = "golem.pack.rejection.wizard" + + pack_id = fields.Many2one('golem.resource.pack', required=True) + reason = fields.Text(required=True) + + @api.multi + def reject(self): + """ Sets pack status to rejected and add reason """ + self.ensure_one() + rejection = self[0] + for reservation in rejection.pack_id.reservation_ids: + if reservation.state == "confirmed": + reservation.write({'state' :'rejected'}) + rejection.pack_id.write({'rejection_reason': rejection.reason}) diff --git a/golem_resource_pack/wizard/golem_pack_rejection_views.xml b/golem_resource_pack/wizard/golem_pack_rejection_views.xml new file mode 100644 index 0000000..b0b01ec --- /dev/null +++ b/golem_resource_pack/wizard/golem_pack_rejection_views.xml @@ -0,0 +1,41 @@ + + + + + + + + GOLEM Pack Rejection Wizard Form + golem.pack.rejection.wizard + +
+ + + + +
+
+
+
+
+
+
From a0fc41cbccc7e0f3f13e9a4f1ad8e68e14ad1d2b Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Sat, 31 Mar 2018 00:33:26 +0200 Subject: [PATCH 09/50] ajout des tests pack --- golem_resource_pack/tests/__init__.py | 19 +++ .../tests/test_golem_resource_pack.py | 145 ++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 golem_resource_pack/tests/__init__.py create mode 100644 golem_resource_pack/tests/test_golem_resource_pack.py diff --git a/golem_resource_pack/tests/__init__.py b/golem_resource_pack/tests/__init__.py new file mode 100644 index 0000000..cbb2d37 --- /dev/null +++ b/golem_resource_pack/tests/__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 test_golem_resource_pack diff --git a/golem_resource_pack/tests/test_golem_resource_pack.py b/golem_resource_pack/tests/test_golem_resource_pack.py new file mode 100644 index 0000000..e824749 --- /dev/null +++ b/golem_resource_pack/tests/test_golem_resource_pack.py @@ -0,0 +1,145 @@ +# -*- 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 Resource Pack testing """ + +import logging +from odoo.tests.common import TransactionCase +from odoo.exceptions import ValidationError +_LOGGER = logging.getLogger(__name__) + + +class TestGolemResourcePack(TransactionCase): + """ GOLEM Resource Reservation testing """ + + def setUp(self, *args, **kwargs): + """ Bootstrap Resource Reservation """ + super(TestGolemResourcePack, self).setUp(*args, **kwargs) + + self.resource = self.env['golem.resource'].create({ + 'name': 'Resource', + 'avaibility_start': '2018-01-01', + 'avaibility_stop': '2020-01-01', + 'availibility_24_7': True + }) + self.resource_val = self.env['golem.resource'].create({ + 'name': 'Resource to validate', + 'avaibility_start': '2018-01-01', + 'avaibility_stop': '2020-01-01', + 'validation_required': True, + 'availibility_24_7': True + }) + + self.partner = self.env['res.partner'].create({'firstname': 'John', + 'lastname': 'DOE', + 'is_company': False}) + + reservation_obj = self.env['golem.resource.reservation'] + self.reservation_1 = reservation_obj.create({ + 'resource_id': self.resource.id, + 'date_start': '2018-02-05 11:00:00', + 'date_stop': '2018-02-05 12:00:00', + 'partner_id': self.partner.id + }) + self.reservation_2 = reservation_obj.create({ + 'resource_id': self.resource.id, + 'date_start': '2018-02-06 11:00:00', + 'date_stop': '2018-02-06 12:00:00', + 'partner_id': self.partner.id + }) + self.reservation_3 = reservation_obj.create({ + 'resource_id': self.resource_val.id, + 'date_start': '2018-02-05 11:00:00', # is monday + 'date_stop': '2018-02-05 12:00:00', + 'partner_id': self.partner.id + }) + self.pack_obj = self.env['golem.resource.pack'] + self.pack_data = { + 'partner_id': self.partner.id + } + + + def test_pack_basic(self): + """ Test pack bases """ + pack = self.pack_obj.create(self.pack_data) + self.assertFalse(pack.reservation_ids) + self.assertFalse(self.reservation_1.pack_id) + pack.reservation_ids = [(4, self.reservation_1.id, 0), + (4, self.reservation_2.id, 0)] + self.assertEqual(pack.reservation_ids[0].state, "draft") + self.assertEqual(self.reservation_1.pack_id.id, pack.id) + self.assertEqual(pack.state, "draft") + self.assertEqual(pack.reservation_count, 2) + #confirm pack ==> all validated + pack.state_confirm()#no validation required + self.assertEqual(pack.reservation_ids[0].state, "validated") + self.assertEqual(pack.state, "validated") + #pack draft ==> all draft + pack.state_draft() + self.assertEqual(pack.reservation_ids[0].state, "draft") + self.assertEqual(pack.state, "draft") + # confirm pack and draft reservation ==> pack draft + pack.state_confirm() + pack.reservation_ids[0].state_draft() + self.assertEqual(pack.reservation_ids[0].state, "draft") + self.assertEqual(pack.state, "draft") + #confirm reservation ==> pack validated + pack.reservation_ids[0].state_confirm() + self.assertEqual(pack.reservation_ids[0].state, "validated") + self.assertEqual(pack.state, "validated") + pack.reservation_ids=[(5,0,0)] + self.assertFalse(pack.reservation_ids) + self.assertEqual(pack.reservation_count, 0) + + + def test_pack_validation(self): + """ Test pack validation """ + pack = self.pack_obj.create(self.pack_data) + self.assertFalse(pack.reservation_ids) + self.assertFalse(self.reservation_1.pack_id) + pack.reservation_ids = [(4, self.reservation_1.id, 0), + (4, self.reservation_3.id, 0)] + self.assertEqual(pack.reservation_ids[0].state, "draft") + self.assertEqual(self.reservation_1.pack_id.id, pack.id) + self.assertEqual(pack.state, "draft") + pack.state_confirm()#validation required + self.assertEqual(pack.state, "confirmed") + pack.state_validated() + self.assertEqual(pack.state, "validated") + self.assertEqual(pack.reservation_ids[0].state, "validated") + self.assertEqual(pack.reservation_ids[1].state, "validated") + + def test_pack_rejection(self): + """ test pack rejection """ + pack = self.pack_obj.create(self.pack_data) + self.assertFalse(pack.reservation_ids) + self.assertFalse(self.reservation_1.pack_id) + pack.reservation_ids = [(4, self.reservation_1.id, 0), + (4, self.reservation_3.id, 0)] + self.assertEqual(pack.reservation_ids[0].state, "draft") + self.assertEqual(self.reservation_1.pack_id.id, pack.id) + self.assertEqual(pack.state, "draft") + pack.state_confirm()#validation required + rej_wizard = self.env['golem.pack.rejection.wizard'].create({ + 'pack_id': pack.id, + 'reason' : 'reason1' + }) + rej_wizard.reject() + self.assertEqual(pack.state, "rejected") + self.assertEqual(self.reservation_3.state, "rejected") + self.assertEqual(pack.rejection_reason, 'reason1') From 66c01206f0ff4dcc5d570e062b5d225ab56e4440 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Sat, 31 Mar 2018 02:47:05 +0200 Subject: [PATCH 10/50] contrainte sur les clients multiples --- golem_resource_pack/models/golem_resource_pack.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/golem_resource_pack/models/golem_resource_pack.py b/golem_resource_pack/models/golem_resource_pack.py index 69fda75..279aac2 100644 --- a/golem_resource_pack/models/golem_resource_pack.py +++ b/golem_resource_pack/models/golem_resource_pack.py @@ -109,8 +109,13 @@ class GolemResourcePack(models.Model): for pack in self: pack.name = u'{}/{}'.format(pack.partner_id.name, pack.create_date) + @api.multi + @api.constrains('reservation_ids') + def check_reservation_partner(self): + for pack in self: + if len(filter(lambda x: x.partner_id == pack.partner_id, pack.reservation_ids)) < len(pack.reservation_ids): + raise ValidationError(_('Pack client should be the same for all reservations')) - #@api.constrains('reservation_ids.state') @api.multi @api.depends('reservation_ids') def _compute_pack_state(self): From 9961933f9618541cc50f2ae209d131c5e87a9baa Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Sat, 31 Mar 2018 17:17:08 +0200 Subject: [PATCH 11/50] refactoration de code --- .../models/golem_resource_pack.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/golem_resource_pack/models/golem_resource_pack.py b/golem_resource_pack/models/golem_resource_pack.py index 279aac2..fa176e5 100644 --- a/golem_resource_pack/models/golem_resource_pack.py +++ b/golem_resource_pack/models/golem_resource_pack.py @@ -30,19 +30,21 @@ class GolemResourcePack(models.Model): name = fields.Char(compute='_compute_name', store=True) reservation_ids = fields.One2many('golem.resource.reservation', 'pack_id', - readonly=True, states={'draft': [('readonly', False)]}, - track_visibility='onchange') + readonly=True, track_visibility='onchange', + states={'draft': [('readonly', False)], + False : [('readonly', False)]}) note = fields.Text(help='Notes, optional subject for the reservation, reason', - readonly=True, states={'draft': [('readonly', False)]}, - track_visibility='onchange') + track_visibility='onchange',readonly=True, + states={'draft': [('readonly', False)], + False : [('readonly', False)]}) user_id = fields.Many2one('res.users', required=True, index=True, readonly=True, string='User', default=lambda self: self.env.user) - partner_id = fields.Many2one('res.partner', string='On behalf of', - required=True, index=True, readonly=True, - states={'draft': [('readonly', False)]}, - track_visibility='onchange') + partner_id = fields.Many2one('res.partner', string='On behalf of', required=True, + index=True, track_visibility='onchange', readonly=True, + states={'draft': [('readonly', False)], + False : [('readonly', False)]}) state = fields.Selection([('canceled', 'Canceled'), ('draft', 'Draft'), ('confirmed', 'Confirmed'), From 7223afa48649271ce9cd7e62dc91d3a42f97975b Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Sun, 1 Apr 2018 02:02:22 +0200 Subject: [PATCH 12/50] Ajout des tests pour facturation des packs --- .../models/golem_resource_pack.py | 27 ++++- .../security/ir.model.access.csv | 3 - .../__init__.py} | 15 +-- .../tests/test_golem_pack_invoice.py | 114 ++++++++++++++++++ 4 files changed, 137 insertions(+), 22 deletions(-) delete mode 100644 golem_resource_pack_account/security/ir.model.access.csv rename golem_resource_pack_account/{models/golem_resource_reservation.py => tests/__init__.py} (67%) create mode 100644 golem_resource_pack_account/tests/test_golem_pack_invoice.py diff --git a/golem_resource_pack_account/models/golem_resource_pack.py b/golem_resource_pack_account/models/golem_resource_pack.py index fc80578..c541dad 100644 --- a/golem_resource_pack_account/models/golem_resource_pack.py +++ b/golem_resource_pack_account/models/golem_resource_pack.py @@ -32,21 +32,38 @@ class GolemResourcePack(models.Model): copy=False) invoice_amount_total = fields.Monetary(related='invoice_id.amount_total') currency_id = fields.Many2one(related='invoice_id.currency_id') - is_products_set = fields.Boolean(compute="compute_is_products_set") + is_products_set = fields.Boolean(compute="_compute_is_products_set") @api.multi - def compute_is_products_set(self): + def _compute_is_products_set(self): + """ compute is_products_set """ for pack in self: - product_list = list(map(lambda x: x.resource_product_id, pack.reservation_ids)) - if len(filter(lambda x: x.id == False, product_list)) > 0: + if len(filter(lambda x: x.resource_product_id.id is False, pack.reservation_ids)) \ + > 0: pack.is_products_set = False else: pack.is_products_set = True + @api.multi + def chek_pack_to_invoice(self): + """ chek pack before invoicing """ + for pack in self: + if pack.state != 'validated': + raise ValidationError(_('The current pack is not validated, please validate ' + 'it before creating invoice')) + elif not pack.is_products_set: + raise ValidationError(_('You can not create an invoice for a pack without ' + 'linked product on every resource reserved.')) + elif pack.invoice_id.id: + raise ValidationError(_('You can not create an invoice as there ' + 'is already one.')) + + @api.multi def create_invoice(self): """ Invoice creation """ for pack in self: + pack.chek_pack_to_invoice() pack.reservation_ids.check_before_invoicing() inv_obj = self.env['account.invoice'] partner_id = pack.partner_id @@ -56,7 +73,7 @@ class GolemResourcePack(models.Model): 'reference': False, 'account_id': partner_id.property_account_receivable_id.id, 'partner_id': partner_id.id - }) + }) pack.invoice_id = invoice_id.id pack.reservation_ids.create_invoice_line(invoice_id) diff --git a/golem_resource_pack_account/security/ir.model.access.csv b/golem_resource_pack_account/security/ir.model.access.csv deleted file mode 100644 index 796d31b..0000000 --- a/golem_resource_pack_account/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_golem_resource_pack_user,Access GOLEM Resource Pack User,model_golem_resource_pack,golem_base.group_golem_user,1,0,0,0 -access_golem_resource_pack_manager,Access GOLEM Resource Pack Manager,model_golem_resource_pack,golem_base.group_golem_manager,1,1,1,1 diff --git a/golem_resource_pack_account/models/golem_resource_reservation.py b/golem_resource_pack_account/tests/__init__.py similarity index 67% rename from golem_resource_pack_account/models/golem_resource_reservation.py rename to golem_resource_pack_account/tests/__init__.py index bf4c7c6..69aaa1d 100644 --- a/golem_resource_pack_account/models/golem_resource_reservation.py +++ b/golem_resource_pack_account/tests/__init__.py @@ -15,17 +15,4 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - -""" GOLEM Resource Reservation """ - -from math import modf -from datetime import timedelta -from odoo import models, fields, api, _ -from odoo.exceptions import ValidationError - - -class GolemResourceReservation(models.Model): - """ GOLEM Resource Reservation Model """ - _inherit = 'golem.resource.reservation' - - pack_id = fields.Many2one('golem_resource_reservation', 'Reservation Pack') +from . import test_golem_pack_invoice diff --git a/golem_resource_pack_account/tests/test_golem_pack_invoice.py b/golem_resource_pack_account/tests/test_golem_pack_invoice.py new file mode 100644 index 0000000..29961a5 --- /dev/null +++ b/golem_resource_pack_account/tests/test_golem_pack_invoice.py @@ -0,0 +1,114 @@ +# -*- 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 Resource Reservation testing """ + +import logging +from odoo.tests.common import TransactionCase +from odoo.exceptions import ValidationError +_LOGGER = logging.getLogger(__name__) + + +class TestGolemResourcePack(TransactionCase): + """ GOLEM Resource Pack testing """ + + def setUp(self, *args, **kwargs): + """ Bootstrap Resource Reservation """ + super(TestGolemResourcePack, self).setUp(*args, **kwargs) + # set product + self.product = self.env['product.template'].create({ + 'name': 'Product', + 'categ_id': self.env.ref('product.product_category_all').id, + 'list_price': 7.0, + 'type': 'service', + 'uom_id': self.env.ref('product.product_uom_hour').id, + 'uom_po_id': self.env.ref('product.product_uom_hour').id, + 'property_account_income_id': self.env.ref('l10n_fr.pcg_706').id + }) + #set resources + self.resource_1 = self.env['golem.resource'].create({ + 'name': 'Resource1', + 'product_tmpl_id': self.product.id, + 'avaibility_start': '2018-01-01', + 'avaibility_stop': '2020-01-01', + 'availibility_24_7': True + }) + self.resource_2 = self.env['golem.resource'].create({ + 'name': 'Resource2', + 'avaibility_start': '2018-01-01', + 'avaibility_stop': '2020-01-01', + 'availibility_24_7': True + }) + + #set partners + self.partner_1 = self.env['res.partner'].create({'firstname': 'John', + 'lastname': 'DOE', + 'is_company': False}) + self.partner_2 = self.env['res.partner'].create({'firstname': 'John2', + 'lastname': 'DOE2', + 'is_company': False}) + + # set reservations + self.reservation_1 = self.env['golem.resource.reservation'].create({ + 'resource_id': self.resource_1.id, + 'date_start': '2018-02-05 11:00:00', + 'date_stop': '2018-02-05 12:00:00', + 'partner_id': self.partner_1.id + }) + self.reservation_2 = self.env['golem.resource.reservation'].create({ + 'resource_id': self.resource_1.id, + 'date_start': '2018-02-06 11:00:00', + 'date_stop': '2018-02-06 12:00:00', + 'partner_id': self.partner_1.id + }) + + #set pack env + self.pack_obj = self.env['golem.resource.pack'] + self.pack_data = { + 'partner_id': self.partner_1.id, + 'reservation_ids': [(4, self.reservation_1.id, 0), + (4, self.reservation_2.id, 0)]} + + + def test_pack_invoice_basic(self): + """ Test pack invoice basic """ + pack = self.pack_obj.create(self.pack_data) + pack.state_confirm() + pack.create_invoice() + self.assertTrue(pack.invoice_id.id) + self.assertEqual(pack.invoice_state, 'draft') + + def test_unallowed_pack_invoice(self): + """ Test unallowed pack invoice cases """ + pack = self.pack_obj.create(self.pack_data) + with self.assertRaises(ValidationError) as err: + pack.create_invoice() + self.assertIn(u'current pack is not validated', err.exception.args[0]) + self.reservation_2.write({'resource_id': self.resource_2.id})#no product linked + pack.state_confirm() + with self.assertRaises(ValidationError) as err: + pack.create_invoice() + self.assertIn(u'linked product on every resource', err.exception.args[0]) + pack.state_draft() + self.reservation_2.write({'resource_id': self.resource_1.id})# with product linked + pack.state_confirm() + pack.create_invoice() + self.assertTrue(pack.invoice_id.id) + with self.assertRaises(ValidationError) as err: + pack.create_invoice() + self.assertIn(u'can not create an invoice as there', err.exception.args[0]) From 08eb3ecb4baa2c1e4539ec67a42c739777d53414 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Tue, 3 Apr 2018 12:33:31 +0200 Subject: [PATCH 13/50] list des factures du meme clients --- golem_resource_account/__manifest__.py | 5 +- .../models/golem_resource_reservation.py | 16 ++++ .../golem_resource_reservation_views.xml | 2 + golem_resource_account/wizard/__init__.py | 3 +- .../golem_reservation_add_to_invoice.py | 68 +++++++++++++++ ...golem_reservation_add_to_invoice_views.xml | 85 +++++++++++++++++++ 6 files changed, 176 insertions(+), 3 deletions(-) create mode 100644 golem_resource_account/wizard/golem_reservation_add_to_invoice.py create mode 100644 golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml diff --git a/golem_resource_account/__manifest__.py b/golem_resource_account/__manifest__.py index fb647c3..7e36e7f 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.1.3', + 'version': '10.0.0.1.4', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', @@ -28,5 +28,6 @@ 'installable': True, 'depends': ['golem_resource', 'account'], 'data': ['wizard/golem_reservation_invoice_views.xml', - 'views/golem_resource_reservation_views.xml'] + 'views/golem_resource_reservation_views.xml', + 'wizard/golem_reservation_add_to_invoice_views.xml'] } diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index a18ad91..3704cb0 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -117,3 +117,19 @@ class GolemResourceReservation(models.Model): 'res_id': reservation.invoice_id.id, 'view_mode': 'form', 'view_id': self.env.ref('account.invoice_form').id} + @api.multi + def add_to_invoice(self): + """ Add reservation to existing invoice""" + for reservation in self: + partner = reservation.partner_id + invoice_list = self.env['account.invoice'].search([('partner_id', '=', partner.id), + ('state', '=', 'draft')]) + #test if none + invoice_ids = invoice_list.mapped('id') + return {'name' : ("partner's invoice list"), + 'type' : 'ir.actions.act_window', + 'res_model' : 'golem.reservation.add.to.invoice.wizard', + 'context': {'default_invoice_ids': invoice_ids}, + 'view_mode': 'form', + 'flags': {'initial_mode': 'view'}, + 'target': 'new'} diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml index a17150c..b544466 100644 --- a/golem_resource_account/views/golem_resource_reservation_views.xml +++ b/golem_resource_account/views/golem_resource_reservation_views.xml @@ -43,6 +43,8 @@ along with this program. If not, see . attrs="{'invisible': ['|', ('state', '!=', 'validated'), '|', ('resource_product_id', '=', False), ('invoice_id', '!=', False)]}" /> . -from . import golem_reservation_invoice +from . import golem_reservation_invoice, \ +golem_reservation_add_to_invoice diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py new file mode 100644 index 0000000..635d2fc --- /dev/null +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py @@ -0,0 +1,68 @@ +# -*- 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 Reservation's Adding to invoice wizard""" + +import logging +from odoo import models, fields, api, _ +_LOGGER = logging.getLogger(__name__) + +class GolemReservationAddToInvoiceWizard(models.TransientModel): + """GOLEM Resrvation Add to Invoice Wizard """ + _name = 'golem.reservation.add.to.invoice.wizard' + + state = fields.Selection([('init', 'Init'), ('final', 'Final')], + default='init') + invoice_ids = fields.Many2many('account.invoice', string="Partner invoice list") + + """keyword = fields.Char(required=True) + member_ids = fields.Many2many('golem.member', string='Members') + contact_ids = fields.Many2many('res.partner', string='Contacts') + + @api.multi + def action(self): + + self.ensure_one() + _LOGGER.warning(self[0].contact_ids) + _LOGGER.warning(self[0].member_ids) + return {'name' : _('Search results'), + 'type' : 'ir.actions.act_window', + 'res_model' : self._name, + 'res_id': self[0].id, + 'view_mode': 'form', + 'target': 'new'} + + @api.multi + def new_search(self): + + self[0].write({'member_ids': [(6, False, [])], + 'contact_ids': [(6, False, [])], + 'state': 'init'}) + return self[0].action() + + @api.multi + def search_partners(self): + + self.ensure_one() + domain = ['|', + ('name', 'ilike', self[0].keyword), + ('email', 'ilike', self[0].keyword)] + partner_ids = self.env['res.partner'].search(domain) + self[0].write({'contact_ids': [(6, False, partner_ids.ids)], + 'member_ids': [(6, False, partner_ids.mapped('member_id').ids)], + 'state': 'final'}) + return self[0].action()""" diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml new file mode 100644 index 0000000..4b78b01 --- /dev/null +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml @@ -0,0 +1,85 @@ + + + + + + + GOLEM Member Precreation Search Form + golem.reservation.add.to.invoice.wizard + +
+ + + + +
+ + + +
+
From 4712b3e689609528e18662efe3987b049abb06ba Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 4 Apr 2018 17:57:01 +0200 Subject: [PATCH 14/50] fonction d'ajout de reservation au facture --- golem_resource_account/models/__init__.py | 2 +- .../models/account_invoice.py | 35 ++++++++++ .../models/golem_resource_reservation.py | 26 ++++--- .../golem_reservation_add_to_invoice.py | 9 ++- ...golem_reservation_add_to_invoice_views.xml | 68 ++++--------------- 5 files changed, 73 insertions(+), 67 deletions(-) create mode 100644 golem_resource_account/models/account_invoice.py diff --git a/golem_resource_account/models/__init__.py b/golem_resource_account/models/__init__.py index 15dcb5c..aaac7ae 100644 --- a/golem_resource_account/models/__init__.py +++ b/golem_resource_account/models/__init__.py @@ -17,4 +17,4 @@ # along with this program. If not, see . -from . import golem_resource_reservation +from . import golem_resource_reservation, account_invoice diff --git a/golem_resource_account/models/account_invoice.py b/golem_resource_account/models/account_invoice.py new file mode 100644 index 0000000..35f530c --- /dev/null +++ b/golem_resource_account/models/account_invoice.py @@ -0,0 +1,35 @@ +# -*- 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 Resource Reservation Adaptation""" + +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class AccountInvoice(models.Model): + """ Account Invoice """ + _inherit = 'account.invoice' + + @api.multi + def add_to_invoice(self): + """Add reservation to existing invoice """ + for invoice in self: + reservation_id = self._context.get('reservation_id') + reservation = self.env['golem.resource.reservation'].browse(reservation_id) + reservation.create_invoice_line(invoice) diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 3704cb0..1067bf1 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -122,14 +122,20 @@ class GolemResourceReservation(models.Model): """ Add reservation to existing invoice""" for reservation in self: partner = reservation.partner_id - invoice_list = self.env['account.invoice'].search([('partner_id', '=', partner.id), - ('state', '=', 'draft')]) + domain = [('partner_id', '=', partner.id), + ('state', '=', 'draft')] + invoice_list = self.env['account.invoice'].search(domain) #test if none - invoice_ids = invoice_list.mapped('id') - return {'name' : ("partner's invoice list"), - 'type' : 'ir.actions.act_window', - 'res_model' : 'golem.reservation.add.to.invoice.wizard', - 'context': {'default_invoice_ids': invoice_ids}, - 'view_mode': 'form', - 'flags': {'initial_mode': 'view'}, - 'target': 'new'} + if invoice_list: + invoice_ids = invoice_list.mapped('id') + return {'name' : ("partner's invoice list"), + 'type' : 'ir.actions.act_window', + 'res_model' : 'golem.reservation.add.to.invoice.wizard', + 'context': {'default_invoice_ids': invoice_ids, + 'default_reservation_id': reservation.id}, + 'view_mode': 'form', + 'flags': {'initial_mode': 'view'}, + 'target': 'new'} + else: + raise ValidationError(_('There is no existing invoice for the current client, ' + 'please create new one to invoice this reservation')) diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py index 635d2fc..aaf5111 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py @@ -25,9 +25,14 @@ class GolemReservationAddToInvoiceWizard(models.TransientModel): """GOLEM Resrvation Add to Invoice Wizard """ _name = 'golem.reservation.add.to.invoice.wizard' - state = fields.Selection([('init', 'Init'), ('final', 'Final')], - default='init') + #state = fields.Selection([('init', 'Init'), ('final', 'Final')], + # default='init') invoice_ids = fields.Many2many('account.invoice', string="Partner invoice list") + reservation_id = fields.Many2one('golem.resource.reservation') + + @api.multi + def add(self): + print '__________________hjt______________________' """keyword = fields.Char(required=True) member_ids = fields.Many2many('golem.member', string='Members') diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml index 4b78b01..cbf168c 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml @@ -19,67 +19,27 @@ along with this program. If not, see . - - GOLEM Member Precreation Search Form + + GOLEM Reservation Add to invoice Form golem.reservation.add.to.invoice.wizard
- - - - -
- - - +
From 53e28fec61d2d299ad80bda48a4f0fa4056c510b Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 6 Apr 2018 14:38:30 +0200 Subject: [PATCH 15/50] =?UTF-8?q?filtre=20ressources=20li=C3=A9es=20aux=20?= =?UTF-8?q?produits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golem_resource/__manifest__.py | 5 +-- golem_resource/models/__init__.py | 3 +- golem_resource/models/product_template.py | 27 +++++++++++++++ .../views/product_template_views.xml | 33 +++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 golem_resource/models/product_template.py create mode 100644 golem_resource/views/product_template_views.xml diff --git a/golem_resource/__manifest__.py b/golem_resource/__manifest__.py index 7d2daa2..25a50fc 100644 --- a/golem_resource/__manifest__.py +++ b/golem_resource/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM non-profit resources', 'summary': 'GOLEM resources management', 'description': ''' GOLEM resources management ''', - 'version': '10.0.1.13.1', + 'version': '10.0.1.13.2', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', @@ -32,5 +32,6 @@ 'views/golem_resource_reservation_views.xml', 'views/golem_resource_timetable_views.xml', 'wizard/golem_reservation_rejection_views.xml', - 'security/ir.model.access.csv'] + 'security/ir.model.access.csv', + 'views/product_template_views.xml'] } diff --git a/golem_resource/models/__init__.py b/golem_resource/models/__init__.py index d3aab06..af90c20 100644 --- a/golem_resource/models/__init__.py +++ b/golem_resource/models/__init__.py @@ -19,4 +19,5 @@ from . import golem_resource_type, \ golem_resource_timetable, \ golem_resource, \ - golem_resource_reservation + golem_resource_reservation, \ + product_template diff --git a/golem_resource/models/product_template.py b/golem_resource/models/product_template.py new file mode 100644 index 0000000..641acb2 --- /dev/null +++ b/golem_resource/models/product_template.py @@ -0,0 +1,27 @@ +# -*- 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 . + +""" Product Template """ + +from odoo import models, fields + +class ProductTemplate(models.Model): + """ Product Template Resource Adaptation """ + _inherit = "product.template" + + resource_ids = fields.One2many('golem.resource', 'product_tmpl_id') diff --git a/golem_resource/views/product_template_views.xml b/golem_resource/views/product_template_views.xml new file mode 100644 index 0000000..89cb3dd --- /dev/null +++ b/golem_resource/views/product_template_views.xml @@ -0,0 +1,33 @@ + + + + + + + product.template.inherit.resource.search + product.template + + + + + + + + + From 2abaabc002d0e03cd1bb918894effe02c80c6d81 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 11 Apr 2018 21:27:07 +0200 Subject: [PATCH 16/50] 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 17/50] 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 18/50] 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 19/50] =?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 20/50] =?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 6b9731335efbb5ecb38987ff2e504c0e0afc281b Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Apr 2018 16:32:50 +0200 Subject: [PATCH 21/50] [IMP][REF]GOLEM Resource : make resource product per default --- golem_resource/views/golem_resource_views.xml | 3 --- golem_resource/views/product_template_views.xml | 14 +++++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/golem_resource/views/golem_resource_views.xml b/golem_resource/views/golem_resource_views.xml index 9120e28..7fb2a25 100644 --- a/golem_resource/views/golem_resource_views.xml +++ b/golem_resource/views/golem_resource_views.xml @@ -135,9 +135,6 @@ along with this program. If not, see . - diff --git a/golem_resource/views/product_template_views.xml b/golem_resource/views/product_template_views.xml index 89cb3dd..65a10ee 100644 --- a/golem_resource/views/product_template_views.xml +++ b/golem_resource/views/product_template_views.xml @@ -18,7 +18,8 @@ along with this program. If not, see . --> - + + product.template.inherit.resource.search product.template @@ -29,5 +30,16 @@ along with this program. If not, see .
+ + + + + + + From 408ae9a8c3035221e87f947191f346fee22da64e Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Apr 2018 16:33:03 +0200 Subject: [PATCH 22/50] [I18N]GOLEM Resource : updated translation --- golem_resource/i18n/fr.po | 52 ++++++++++++++++++++++---- golem_resource/i18n/golem_resource.pot | 52 ++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 16 deletions(-) diff --git a/golem_resource/i18n/fr.po b/golem_resource/i18n/fr.po index ddc67ef..bb80159 100644 --- a/golem_resource/i18n/fr.po +++ b/golem_resource/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-26 15:36+0000\n" -"PO-Revision-Date: 2018-03-26 15:36+0000\n" +"POT-Creation-Date: 2018-04-16 14:29+0000\n" +"PO-Revision-Date: 2018-04-16 14:29+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,6 +21,16 @@ msgstr "" msgid "24/7 availibility" msgstr "Disponibilité 24h/24 7j/7" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "30 Days Reservations" +msgstr "Dans les 30 jours" + +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "7 Days Reservations" +msgstr "Dans les 7 jours" + #. module: golem_resource #: model:ir.model.fields,help:golem_resource.field_golem_resource_product_tmpl_id msgid "A generic product can be linked, in order to sell reservations (work in progress)" @@ -123,6 +133,11 @@ msgstr "Créé le" msgid "Day" msgstr "Jour" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "Day Reservation" +msgstr "Démarre ce jour" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_reservation_day_start msgid "Day start" @@ -228,6 +243,11 @@ msgstr "Dernière mise à jour par" msgid "Last Updated on" msgstr "Dernière mise à jour le" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.product_template_search_inherit_resource_view +msgid "Linked To A Resource" +msgstr "Lié à une ressource" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_product_tmpl_id #: model:ir.ui.view,arch_db:golem_resource.golem_resource_view_search @@ -313,6 +333,16 @@ msgstr "Merci de saisir le motif du refus" msgid "Please save the resource before fixing the timetable availibility\"" msgstr "Merci de sauvegarder la ressource avant de pouvoir définir ses disponibilités\"" +#. module: golem_resource +#: model:ir.model,name:golem_resource.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: golem_resource +#: model:ir.actions.act_window,name:golem_resource.golem_resource_product_action +msgid "Products" +msgstr "Articles" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_reservation_rejection_wizard_reason msgid "Reason" @@ -366,6 +396,11 @@ msgstr "Réservations" msgid "Resource" msgstr "Ressource" +#. module: golem_resource +#: model:ir.ui.menu,name:golem_resource.product_template_menu +msgid "Resource Products" +msgstr "Articles liés à des ressources" + #. module: golem_resource #: code:addons/golem_resource/models/golem_resource.py:64 #, python-format @@ -379,7 +414,7 @@ msgid "Resource Reservation list" msgstr "Liste des réservations" #. module: golem_resource -#: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_id_4449 +#: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_id_4023 #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_name msgid "Resource Type" msgstr "Type de ressource" @@ -390,6 +425,12 @@ msgstr "Type de ressource" msgid "Resource Types" msgstr "Types de ressource" +#. module: golem_resource +#: model:ir.model.fields,field_description:golem_resource.field_product_product_resource_ids +#: model:ir.model.fields,field_description:golem_resource.field_product_template_resource_ids +msgid "Resource ids" +msgstr "Ressources" + #. module: golem_resource #: sql_constraint:golem.resource.type:0 msgid "Resource type must be unique." @@ -409,11 +450,6 @@ msgstr "Ressources" msgid "Saturday" msgstr "Samedi" -#. module: golem_resource -#: model:ir.ui.menu,name:golem_resource.product_template_menu -msgid "Sellable Products" -msgstr "Articles en vente" - #. module: golem_resource #: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_form msgid "Set to draft" diff --git a/golem_resource/i18n/golem_resource.pot b/golem_resource/i18n/golem_resource.pot index 80852e2..5b1522f 100644 --- a/golem_resource/i18n/golem_resource.pot +++ b/golem_resource/i18n/golem_resource.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-26 15:37+0000\n" -"PO-Revision-Date: 2018-03-26 15:37+0000\n" +"POT-Creation-Date: 2018-04-16 14:29+0000\n" +"PO-Revision-Date: 2018-04-16 14:29+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,6 +21,16 @@ msgstr "" msgid "24/7 availibility" msgstr "" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "30 Days Reservations" +msgstr "" + +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "7 Days Reservations" +msgstr "" + #. module: golem_resource #: model:ir.model.fields,help:golem_resource.field_golem_resource_product_tmpl_id msgid "A generic product can be linked, in order to sell reservations (work in progress)" @@ -123,6 +133,11 @@ msgstr "" msgid "Day" msgstr "" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "Day Reservation" +msgstr "" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_reservation_day_start msgid "Day start" @@ -228,6 +243,11 @@ msgstr "" msgid "Last Updated on" msgstr "" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.product_template_search_inherit_resource_view +msgid "Linked To A Resource" +msgstr "" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_product_tmpl_id #: model:ir.ui.view,arch_db:golem_resource.golem_resource_view_search @@ -313,6 +333,16 @@ msgstr "" msgid "Please save the resource before fixing the timetable availibility\"" msgstr "" +#. module: golem_resource +#: model:ir.model,name:golem_resource.model_product_template +msgid "Product Template" +msgstr "" + +#. module: golem_resource +#: model:ir.actions.act_window,name:golem_resource.golem_resource_product_action +msgid "Products" +msgstr "" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_reservation_rejection_wizard_reason msgid "Reason" @@ -366,6 +396,11 @@ msgstr "" msgid "Resource" msgstr "" +#. module: golem_resource +#: model:ir.ui.menu,name:golem_resource.product_template_menu +msgid "Resource Products" +msgstr "" + #. module: golem_resource #: code:addons/golem_resource/models/golem_resource.py:64 #, python-format @@ -379,7 +414,7 @@ msgid "Resource Reservation list" msgstr "" #. module: golem_resource -#: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_id_4449 +#: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_id_4023 #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_name msgid "Resource Type" msgstr "" @@ -390,6 +425,12 @@ msgstr "" msgid "Resource Types" msgstr "" +#. module: golem_resource +#: model:ir.model.fields,field_description:golem_resource.field_product_product_resource_ids +#: model:ir.model.fields,field_description:golem_resource.field_product_template_resource_ids +msgid "Resource ids" +msgstr "" + #. module: golem_resource #: sql_constraint:golem.resource.type:0 msgid "Resource type must be unique." @@ -409,11 +450,6 @@ msgstr "" msgid "Saturday" msgstr "" -#. module: golem_resource -#: model:ir.ui.menu,name:golem_resource.product_template_menu -msgid "Sellable Products" -msgstr "" - #. module: golem_resource #: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_form msgid "Set to draft" From 1398cb945d323df47286adbd5f0a085c55a3f7b3 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Mon, 16 Apr 2018 17:10:22 +0200 Subject: [PATCH 23/50] 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 24/50] 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 6d163a7a9379e2228617bfb8d315bd3a3a6eb56e Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Apr 2018 17:55:02 +0200 Subject: [PATCH 25/50] [REF]GOLEM Resource Account : add to invoice refactoring / small enhancements --- golem_resource_account/__manifest__.py | 2 +- .../models/account_invoice.py | 9 +++++- .../models/golem_resource_reservation.py | 15 +++++---- .../golem_reservation_add_to_invoice.py | 31 ++++--------------- ...golem_reservation_add_to_invoice_views.xml | 7 ++--- 5 files changed, 25 insertions(+), 39 deletions(-) diff --git a/golem_resource_account/__manifest__.py b/golem_resource_account/__manifest__.py index 7e36e7f..3560e1b 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.1.4', + 'version': '10.0.0.2.0', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_resource_account/models/account_invoice.py b/golem_resource_account/models/account_invoice.py index 35f530c..e0360f0 100644 --- a/golem_resource_account/models/account_invoice.py +++ b/golem_resource_account/models/account_invoice.py @@ -18,7 +18,7 @@ """ GOLEM Resource Reservation Adaptation""" -from odoo import models, fields, api, _ +from odoo import models, api, _ from odoo.exceptions import ValidationError @@ -31,5 +31,12 @@ class AccountInvoice(models.Model): """Add reservation to existing invoice """ for invoice in self: reservation_id = self._context.get('reservation_id') + if not reservation_id: + raise ValidationError(_('There is no reservation passed through ' + 'context. Please contact your administrator.')) reservation = self.env['golem.resource.reservation'].browse(reservation_id) + if not reservation: + raise ValidationError(_('No reservation has been found with {} ' + 'reservation ID. Please contact your ' + 'administrator.'.format(reservation_id))) reservation.create_invoice_line(invoice) diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 1067bf1..308f680 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -124,18 +124,17 @@ class GolemResourceReservation(models.Model): partner = reservation.partner_id domain = [('partner_id', '=', partner.id), ('state', '=', 'draft')] - invoice_list = self.env['account.invoice'].search(domain) - #test if none - if invoice_list: - invoice_ids = invoice_list.mapped('id') - return {'name' : ("partner's invoice list"), + invoice_ids = self.env['account.invoice'].search(domain) + if invoice_ids: + return {'name' : (_('Partner\'s invoice list')), 'type' : 'ir.actions.act_window', 'res_model' : 'golem.reservation.add.to.invoice.wizard', - 'context': {'default_invoice_ids': invoice_ids, + 'context': {'default_invoice_ids': invoice_ids.ids, 'default_reservation_id': reservation.id}, 'view_mode': 'form', 'flags': {'initial_mode': 'view'}, 'target': 'new'} else: - raise ValidationError(_('There is no existing invoice for the current client, ' - 'please create new one to invoice this reservation')) + raise ValidationError(_('There is no existing invoice for the ' + 'current client, please create new one ' + 'to invoice this reservation')) diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py index aaf5111..8c993ca 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py @@ -17,33 +17,23 @@ # along with this program. If not, see . """ GOLEM Reservation's Adding to invoice wizard""" -import logging from odoo import models, fields, api, _ -_LOGGER = logging.getLogger(__name__) class GolemReservationAddToInvoiceWizard(models.TransientModel): - """GOLEM Resrvation Add to Invoice Wizard """ + """GOLEM Reservation Add to Invoice Wizard """ _name = 'golem.reservation.add.to.invoice.wizard' - #state = fields.Selection([('init', 'Init'), ('final', 'Final')], - # default='init') invoice_ids = fields.Many2many('account.invoice', string="Partner invoice list") reservation_id = fields.Many2one('golem.resource.reservation') - @api.multi - def add(self): - print '__________________hjt______________________' - - """keyword = fields.Char(required=True) + keyword = fields.Char(required=True) member_ids = fields.Many2many('golem.member', string='Members') contact_ids = fields.Many2many('res.partner', string='Contacts') @api.multi def action(self): - + """ Returns action window with current model and instance """ self.ensure_one() - _LOGGER.warning(self[0].contact_ids) - _LOGGER.warning(self[0].member_ids) return {'name' : _('Search results'), 'type' : 'ir.actions.act_window', 'res_model' : self._name, @@ -51,23 +41,14 @@ class GolemReservationAddToInvoiceWizard(models.TransientModel): 'view_mode': 'form', 'target': 'new'} - @api.multi - def new_search(self): - - self[0].write({'member_ids': [(6, False, [])], - 'contact_ids': [(6, False, [])], - 'state': 'init'}) - return self[0].action() - @api.multi def search_partners(self): - + """ Searches partners in name, email """ self.ensure_one() domain = ['|', ('name', 'ilike', self[0].keyword), ('email', 'ilike', self[0].keyword)] partner_ids = self.env['res.partner'].search(domain) self[0].write({'contact_ids': [(6, False, partner_ids.ids)], - 'member_ids': [(6, False, partner_ids.mapped('member_id').ids)], - 'state': 'final'}) - return self[0].action()""" + 'member_ids': [(6, False, partner_ids.mapped('member_id').ids)]}) + return self[0].action() diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml index cbf168c..cec5717 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml @@ -19,20 +19,19 @@ along with this program. If not, see . - + GOLEM Reservation Add to invoice Form golem.reservation.add.to.invoice.wizard - + - - . -from . import golem_reservation_invoice +from . import golem_reservation_invoice, \ +golem_reservation_add_to_invoice diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py new file mode 100644 index 0000000..635d2fc --- /dev/null +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py @@ -0,0 +1,68 @@ +# -*- 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 Reservation's Adding to invoice wizard""" + +import logging +from odoo import models, fields, api, _ +_LOGGER = logging.getLogger(__name__) + +class GolemReservationAddToInvoiceWizard(models.TransientModel): + """GOLEM Resrvation Add to Invoice Wizard """ + _name = 'golem.reservation.add.to.invoice.wizard' + + state = fields.Selection([('init', 'Init'), ('final', 'Final')], + default='init') + invoice_ids = fields.Many2many('account.invoice', string="Partner invoice list") + + """keyword = fields.Char(required=True) + member_ids = fields.Many2many('golem.member', string='Members') + contact_ids = fields.Many2many('res.partner', string='Contacts') + + @api.multi + def action(self): + + self.ensure_one() + _LOGGER.warning(self[0].contact_ids) + _LOGGER.warning(self[0].member_ids) + return {'name' : _('Search results'), + 'type' : 'ir.actions.act_window', + 'res_model' : self._name, + 'res_id': self[0].id, + 'view_mode': 'form', + 'target': 'new'} + + @api.multi + def new_search(self): + + self[0].write({'member_ids': [(6, False, [])], + 'contact_ids': [(6, False, [])], + 'state': 'init'}) + return self[0].action() + + @api.multi + def search_partners(self): + + self.ensure_one() + domain = ['|', + ('name', 'ilike', self[0].keyword), + ('email', 'ilike', self[0].keyword)] + partner_ids = self.env['res.partner'].search(domain) + self[0].write({'contact_ids': [(6, False, partner_ids.ids)], + 'member_ids': [(6, False, partner_ids.mapped('member_id').ids)], + 'state': 'final'}) + return self[0].action()""" diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml new file mode 100644 index 0000000..4b78b01 --- /dev/null +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml @@ -0,0 +1,85 @@ + + + + + + + GOLEM Member Precreation Search Form + golem.reservation.add.to.invoice.wizard + + + + + + + + + + + + From b584cf8bef718357570087d0a2be4251763c3952 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 4 Apr 2018 17:57:01 +0200 Subject: [PATCH 32/50] fonction d'ajout de reservation au facture --- golem_resource_account/models/__init__.py | 2 +- .../models/account_invoice.py | 35 ++++++++++ .../models/golem_resource_reservation.py | 26 ++++--- .../golem_reservation_add_to_invoice.py | 9 ++- ...golem_reservation_add_to_invoice_views.xml | 68 ++++--------------- 5 files changed, 73 insertions(+), 67 deletions(-) create mode 100644 golem_resource_account/models/account_invoice.py diff --git a/golem_resource_account/models/__init__.py b/golem_resource_account/models/__init__.py index 15dcb5c..aaac7ae 100644 --- a/golem_resource_account/models/__init__.py +++ b/golem_resource_account/models/__init__.py @@ -17,4 +17,4 @@ # along with this program. If not, see . -from . import golem_resource_reservation +from . import golem_resource_reservation, account_invoice diff --git a/golem_resource_account/models/account_invoice.py b/golem_resource_account/models/account_invoice.py new file mode 100644 index 0000000..35f530c --- /dev/null +++ b/golem_resource_account/models/account_invoice.py @@ -0,0 +1,35 @@ +# -*- 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 Resource Reservation Adaptation""" + +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class AccountInvoice(models.Model): + """ Account Invoice """ + _inherit = 'account.invoice' + + @api.multi + def add_to_invoice(self): + """Add reservation to existing invoice """ + for invoice in self: + reservation_id = self._context.get('reservation_id') + reservation = self.env['golem.resource.reservation'].browse(reservation_id) + reservation.create_invoice_line(invoice) diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 3704cb0..1067bf1 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -122,14 +122,20 @@ class GolemResourceReservation(models.Model): """ Add reservation to existing invoice""" for reservation in self: partner = reservation.partner_id - invoice_list = self.env['account.invoice'].search([('partner_id', '=', partner.id), - ('state', '=', 'draft')]) + domain = [('partner_id', '=', partner.id), + ('state', '=', 'draft')] + invoice_list = self.env['account.invoice'].search(domain) #test if none - invoice_ids = invoice_list.mapped('id') - return {'name' : ("partner's invoice list"), - 'type' : 'ir.actions.act_window', - 'res_model' : 'golem.reservation.add.to.invoice.wizard', - 'context': {'default_invoice_ids': invoice_ids}, - 'view_mode': 'form', - 'flags': {'initial_mode': 'view'}, - 'target': 'new'} + if invoice_list: + invoice_ids = invoice_list.mapped('id') + return {'name' : ("partner's invoice list"), + 'type' : 'ir.actions.act_window', + 'res_model' : 'golem.reservation.add.to.invoice.wizard', + 'context': {'default_invoice_ids': invoice_ids, + 'default_reservation_id': reservation.id}, + 'view_mode': 'form', + 'flags': {'initial_mode': 'view'}, + 'target': 'new'} + else: + raise ValidationError(_('There is no existing invoice for the current client, ' + 'please create new one to invoice this reservation')) diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py index 635d2fc..aaf5111 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py @@ -25,9 +25,14 @@ class GolemReservationAddToInvoiceWizard(models.TransientModel): """GOLEM Resrvation Add to Invoice Wizard """ _name = 'golem.reservation.add.to.invoice.wizard' - state = fields.Selection([('init', 'Init'), ('final', 'Final')], - default='init') + #state = fields.Selection([('init', 'Init'), ('final', 'Final')], + # default='init') invoice_ids = fields.Many2many('account.invoice', string="Partner invoice list") + reservation_id = fields.Many2one('golem.resource.reservation') + + @api.multi + def add(self): + print '__________________hjt______________________' """keyword = fields.Char(required=True) member_ids = fields.Many2many('golem.member', string='Members') diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml index 4b78b01..cbf168c 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml @@ -19,67 +19,27 @@ along with this program. If not, see . - - GOLEM Member Precreation Search Form + + GOLEM Reservation Add to invoice Form golem.reservation.add.to.invoice.wizard
- - - - -
- - - +
From 7e845ae9324a3e63778da3d41655a1f3179cb00e Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 6 Apr 2018 14:38:30 +0200 Subject: [PATCH 33/50] =?UTF-8?q?filtre=20ressources=20li=C3=A9es=20aux=20?= =?UTF-8?q?produits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golem_resource/__manifest__.py | 5 +-- golem_resource/models/__init__.py | 3 +- golem_resource/models/product_template.py | 27 +++++++++++++++ .../views/product_template_views.xml | 33 +++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 golem_resource/models/product_template.py create mode 100644 golem_resource/views/product_template_views.xml diff --git a/golem_resource/__manifest__.py b/golem_resource/__manifest__.py index 7d2daa2..25a50fc 100644 --- a/golem_resource/__manifest__.py +++ b/golem_resource/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM non-profit resources', 'summary': 'GOLEM resources management', 'description': ''' GOLEM resources management ''', - 'version': '10.0.1.13.1', + 'version': '10.0.1.13.2', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', @@ -32,5 +32,6 @@ 'views/golem_resource_reservation_views.xml', 'views/golem_resource_timetable_views.xml', 'wizard/golem_reservation_rejection_views.xml', - 'security/ir.model.access.csv'] + 'security/ir.model.access.csv', + 'views/product_template_views.xml'] } diff --git a/golem_resource/models/__init__.py b/golem_resource/models/__init__.py index d3aab06..af90c20 100644 --- a/golem_resource/models/__init__.py +++ b/golem_resource/models/__init__.py @@ -19,4 +19,5 @@ from . import golem_resource_type, \ golem_resource_timetable, \ golem_resource, \ - golem_resource_reservation + golem_resource_reservation, \ + product_template diff --git a/golem_resource/models/product_template.py b/golem_resource/models/product_template.py new file mode 100644 index 0000000..641acb2 --- /dev/null +++ b/golem_resource/models/product_template.py @@ -0,0 +1,27 @@ +# -*- 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 . + +""" Product Template """ + +from odoo import models, fields + +class ProductTemplate(models.Model): + """ Product Template Resource Adaptation """ + _inherit = "product.template" + + resource_ids = fields.One2many('golem.resource', 'product_tmpl_id') diff --git a/golem_resource/views/product_template_views.xml b/golem_resource/views/product_template_views.xml new file mode 100644 index 0000000..89cb3dd --- /dev/null +++ b/golem_resource/views/product_template_views.xml @@ -0,0 +1,33 @@ + + + + + + + product.template.inherit.resource.search + product.template + + + + + + + + + From 3ce2f43b356f86ea6173667a297e7c1a6ce13e30 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Apr 2018 16:32:50 +0200 Subject: [PATCH 34/50] [IMP][REF]GOLEM Resource : make resource product per default --- golem_resource/views/golem_resource_views.xml | 3 --- golem_resource/views/product_template_views.xml | 14 +++++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/golem_resource/views/golem_resource_views.xml b/golem_resource/views/golem_resource_views.xml index 9120e28..7fb2a25 100644 --- a/golem_resource/views/golem_resource_views.xml +++ b/golem_resource/views/golem_resource_views.xml @@ -135,9 +135,6 @@ along with this program. If not, see . -
diff --git a/golem_resource/views/product_template_views.xml b/golem_resource/views/product_template_views.xml index 89cb3dd..65a10ee 100644 --- a/golem_resource/views/product_template_views.xml +++ b/golem_resource/views/product_template_views.xml @@ -18,7 +18,8 @@ along with this program. If not, see . --> - + + product.template.inherit.resource.search product.template @@ -29,5 +30,16 @@ along with this program. If not, see . + + + + + + + From c446fccd0354ced056ed0c5b95432bf3f58612c1 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Apr 2018 16:33:03 +0200 Subject: [PATCH 35/50] [I18N]GOLEM Resource : updated translation --- golem_resource/i18n/fr.po | 52 ++++++++++++++++++++++---- golem_resource/i18n/golem_resource.pot | 52 ++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 16 deletions(-) diff --git a/golem_resource/i18n/fr.po b/golem_resource/i18n/fr.po index ddc67ef..bb80159 100644 --- a/golem_resource/i18n/fr.po +++ b/golem_resource/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-26 15:36+0000\n" -"PO-Revision-Date: 2018-03-26 15:36+0000\n" +"POT-Creation-Date: 2018-04-16 14:29+0000\n" +"PO-Revision-Date: 2018-04-16 14:29+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,6 +21,16 @@ msgstr "" msgid "24/7 availibility" msgstr "Disponibilité 24h/24 7j/7" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "30 Days Reservations" +msgstr "Dans les 30 jours" + +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "7 Days Reservations" +msgstr "Dans les 7 jours" + #. module: golem_resource #: model:ir.model.fields,help:golem_resource.field_golem_resource_product_tmpl_id msgid "A generic product can be linked, in order to sell reservations (work in progress)" @@ -123,6 +133,11 @@ msgstr "Créé le" msgid "Day" msgstr "Jour" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "Day Reservation" +msgstr "Démarre ce jour" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_reservation_day_start msgid "Day start" @@ -228,6 +243,11 @@ msgstr "Dernière mise à jour par" msgid "Last Updated on" msgstr "Dernière mise à jour le" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.product_template_search_inherit_resource_view +msgid "Linked To A Resource" +msgstr "Lié à une ressource" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_product_tmpl_id #: model:ir.ui.view,arch_db:golem_resource.golem_resource_view_search @@ -313,6 +333,16 @@ msgstr "Merci de saisir le motif du refus" msgid "Please save the resource before fixing the timetable availibility\"" msgstr "Merci de sauvegarder la ressource avant de pouvoir définir ses disponibilités\"" +#. module: golem_resource +#: model:ir.model,name:golem_resource.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: golem_resource +#: model:ir.actions.act_window,name:golem_resource.golem_resource_product_action +msgid "Products" +msgstr "Articles" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_reservation_rejection_wizard_reason msgid "Reason" @@ -366,6 +396,11 @@ msgstr "Réservations" msgid "Resource" msgstr "Ressource" +#. module: golem_resource +#: model:ir.ui.menu,name:golem_resource.product_template_menu +msgid "Resource Products" +msgstr "Articles liés à des ressources" + #. module: golem_resource #: code:addons/golem_resource/models/golem_resource.py:64 #, python-format @@ -379,7 +414,7 @@ msgid "Resource Reservation list" msgstr "Liste des réservations" #. module: golem_resource -#: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_id_4449 +#: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_id_4023 #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_name msgid "Resource Type" msgstr "Type de ressource" @@ -390,6 +425,12 @@ msgstr "Type de ressource" msgid "Resource Types" msgstr "Types de ressource" +#. module: golem_resource +#: model:ir.model.fields,field_description:golem_resource.field_product_product_resource_ids +#: model:ir.model.fields,field_description:golem_resource.field_product_template_resource_ids +msgid "Resource ids" +msgstr "Ressources" + #. module: golem_resource #: sql_constraint:golem.resource.type:0 msgid "Resource type must be unique." @@ -409,11 +450,6 @@ msgstr "Ressources" msgid "Saturday" msgstr "Samedi" -#. module: golem_resource -#: model:ir.ui.menu,name:golem_resource.product_template_menu -msgid "Sellable Products" -msgstr "Articles en vente" - #. module: golem_resource #: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_form msgid "Set to draft" diff --git a/golem_resource/i18n/golem_resource.pot b/golem_resource/i18n/golem_resource.pot index 80852e2..5b1522f 100644 --- a/golem_resource/i18n/golem_resource.pot +++ b/golem_resource/i18n/golem_resource.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-26 15:37+0000\n" -"PO-Revision-Date: 2018-03-26 15:37+0000\n" +"POT-Creation-Date: 2018-04-16 14:29+0000\n" +"PO-Revision-Date: 2018-04-16 14:29+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,6 +21,16 @@ msgstr "" msgid "24/7 availibility" msgstr "" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "30 Days Reservations" +msgstr "" + +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "7 Days Reservations" +msgstr "" + #. module: golem_resource #: model:ir.model.fields,help:golem_resource.field_golem_resource_product_tmpl_id msgid "A generic product can be linked, in order to sell reservations (work in progress)" @@ -123,6 +133,11 @@ msgstr "" msgid "Day" msgstr "" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search +msgid "Day Reservation" +msgstr "" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_reservation_day_start msgid "Day start" @@ -228,6 +243,11 @@ msgstr "" msgid "Last Updated on" msgstr "" +#. module: golem_resource +#: model:ir.ui.view,arch_db:golem_resource.product_template_search_inherit_resource_view +msgid "Linked To A Resource" +msgstr "" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_product_tmpl_id #: model:ir.ui.view,arch_db:golem_resource.golem_resource_view_search @@ -313,6 +333,16 @@ msgstr "" msgid "Please save the resource before fixing the timetable availibility\"" msgstr "" +#. module: golem_resource +#: model:ir.model,name:golem_resource.model_product_template +msgid "Product Template" +msgstr "" + +#. module: golem_resource +#: model:ir.actions.act_window,name:golem_resource.golem_resource_product_action +msgid "Products" +msgstr "" + #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_reservation_rejection_wizard_reason msgid "Reason" @@ -366,6 +396,11 @@ msgstr "" msgid "Resource" msgstr "" +#. module: golem_resource +#: model:ir.ui.menu,name:golem_resource.product_template_menu +msgid "Resource Products" +msgstr "" + #. module: golem_resource #: code:addons/golem_resource/models/golem_resource.py:64 #, python-format @@ -379,7 +414,7 @@ msgid "Resource Reservation list" msgstr "" #. module: golem_resource -#: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_id_4449 +#: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_id_4023 #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_type_name msgid "Resource Type" msgstr "" @@ -390,6 +425,12 @@ msgstr "" msgid "Resource Types" msgstr "" +#. module: golem_resource +#: model:ir.model.fields,field_description:golem_resource.field_product_product_resource_ids +#: model:ir.model.fields,field_description:golem_resource.field_product_template_resource_ids +msgid "Resource ids" +msgstr "" + #. module: golem_resource #: sql_constraint:golem.resource.type:0 msgid "Resource type must be unique." @@ -409,11 +450,6 @@ msgstr "" msgid "Saturday" msgstr "" -#. module: golem_resource -#: model:ir.ui.menu,name:golem_resource.product_template_menu -msgid "Sellable Products" -msgstr "" - #. module: golem_resource #: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_form msgid "Set to draft" From 95cc14a4ee2e9d395506b4c1ac4f1bc58532a4b0 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Apr 2018 17:55:02 +0200 Subject: [PATCH 36/50] [REF]GOLEM Resource Account : add to invoice refactoring / small enhancements --- golem_resource_account/__manifest__.py | 2 +- .../models/account_invoice.py | 9 +++++- .../models/golem_resource_reservation.py | 15 +++++---- .../golem_reservation_add_to_invoice.py | 31 ++++--------------- ...golem_reservation_add_to_invoice_views.xml | 7 ++--- 5 files changed, 25 insertions(+), 39 deletions(-) diff --git a/golem_resource_account/__manifest__.py b/golem_resource_account/__manifest__.py index 7e36e7f..3560e1b 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.1.4', + 'version': '10.0.0.2.0', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_resource_account/models/account_invoice.py b/golem_resource_account/models/account_invoice.py index 35f530c..e0360f0 100644 --- a/golem_resource_account/models/account_invoice.py +++ b/golem_resource_account/models/account_invoice.py @@ -18,7 +18,7 @@ """ GOLEM Resource Reservation Adaptation""" -from odoo import models, fields, api, _ +from odoo import models, api, _ from odoo.exceptions import ValidationError @@ -31,5 +31,12 @@ class AccountInvoice(models.Model): """Add reservation to existing invoice """ for invoice in self: reservation_id = self._context.get('reservation_id') + if not reservation_id: + raise ValidationError(_('There is no reservation passed through ' + 'context. Please contact your administrator.')) reservation = self.env['golem.resource.reservation'].browse(reservation_id) + if not reservation: + raise ValidationError(_('No reservation has been found with {} ' + 'reservation ID. Please contact your ' + 'administrator.'.format(reservation_id))) reservation.create_invoice_line(invoice) diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 1067bf1..308f680 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -124,18 +124,17 @@ class GolemResourceReservation(models.Model): partner = reservation.partner_id domain = [('partner_id', '=', partner.id), ('state', '=', 'draft')] - invoice_list = self.env['account.invoice'].search(domain) - #test if none - if invoice_list: - invoice_ids = invoice_list.mapped('id') - return {'name' : ("partner's invoice list"), + invoice_ids = self.env['account.invoice'].search(domain) + if invoice_ids: + return {'name' : (_('Partner\'s invoice list')), 'type' : 'ir.actions.act_window', 'res_model' : 'golem.reservation.add.to.invoice.wizard', - 'context': {'default_invoice_ids': invoice_ids, + 'context': {'default_invoice_ids': invoice_ids.ids, 'default_reservation_id': reservation.id}, 'view_mode': 'form', 'flags': {'initial_mode': 'view'}, 'target': 'new'} else: - raise ValidationError(_('There is no existing invoice for the current client, ' - 'please create new one to invoice this reservation')) + raise ValidationError(_('There is no existing invoice for the ' + 'current client, please create new one ' + 'to invoice this reservation')) diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py index aaf5111..8c993ca 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py @@ -17,33 +17,23 @@ # along with this program. If not, see . """ GOLEM Reservation's Adding to invoice wizard""" -import logging from odoo import models, fields, api, _ -_LOGGER = logging.getLogger(__name__) class GolemReservationAddToInvoiceWizard(models.TransientModel): - """GOLEM Resrvation Add to Invoice Wizard """ + """GOLEM Reservation Add to Invoice Wizard """ _name = 'golem.reservation.add.to.invoice.wizard' - #state = fields.Selection([('init', 'Init'), ('final', 'Final')], - # default='init') invoice_ids = fields.Many2many('account.invoice', string="Partner invoice list") reservation_id = fields.Many2one('golem.resource.reservation') - @api.multi - def add(self): - print '__________________hjt______________________' - - """keyword = fields.Char(required=True) + keyword = fields.Char(required=True) member_ids = fields.Many2many('golem.member', string='Members') contact_ids = fields.Many2many('res.partner', string='Contacts') @api.multi def action(self): - + """ Returns action window with current model and instance """ self.ensure_one() - _LOGGER.warning(self[0].contact_ids) - _LOGGER.warning(self[0].member_ids) return {'name' : _('Search results'), 'type' : 'ir.actions.act_window', 'res_model' : self._name, @@ -51,23 +41,14 @@ class GolemReservationAddToInvoiceWizard(models.TransientModel): 'view_mode': 'form', 'target': 'new'} - @api.multi - def new_search(self): - - self[0].write({'member_ids': [(6, False, [])], - 'contact_ids': [(6, False, [])], - 'state': 'init'}) - return self[0].action() - @api.multi def search_partners(self): - + """ Searches partners in name, email """ self.ensure_one() domain = ['|', ('name', 'ilike', self[0].keyword), ('email', 'ilike', self[0].keyword)] partner_ids = self.env['res.partner'].search(domain) self[0].write({'contact_ids': [(6, False, partner_ids.ids)], - 'member_ids': [(6, False, partner_ids.mapped('member_id').ids)], - 'state': 'final'}) - return self[0].action()""" + 'member_ids': [(6, False, partner_ids.mapped('member_id').ids)]}) + return self[0].action() diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml index cbf168c..cec5717 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml @@ -19,20 +19,19 @@ along with this program. If not, see . - + GOLEM Reservation Add to invoice Form golem.reservation.add.to.invoice.wizard
- + - - - + @@ -52,5 +54,6 @@ along with this program. If not, see .
+
From 6ccf24e485cdeca0010dd8b459db0a79aae2be96 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Tue, 17 Apr 2018 08:47:44 +0200 Subject: [PATCH 41/50] [FIX]GOLEM Resource Pack : tests adaptations and fixes after refactoring --- golem_resource_pack/tests/test_golem_resource_pack.py | 1 + golem_resource_pack_account/models/golem_resource_pack.py | 2 +- golem_resource_pack_account/tests/test_golem_pack_invoice.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/golem_resource_pack/tests/test_golem_resource_pack.py b/golem_resource_pack/tests/test_golem_resource_pack.py index 1cc5274..a5dbe06 100644 --- a/golem_resource_pack/tests/test_golem_resource_pack.py +++ b/golem_resource_pack/tests/test_golem_resource_pack.py @@ -69,6 +69,7 @@ class TestGolemResourcePack(TransactionCase): }) self.pack_obj = self.env['golem.resource.pack'] self.pack_data = { + 'name': 'Pack Test', 'partner_id': self.partner.id } diff --git a/golem_resource_pack_account/models/golem_resource_pack.py b/golem_resource_pack_account/models/golem_resource_pack.py index 7906953..9d75e47 100644 --- a/golem_resource_pack_account/models/golem_resource_pack.py +++ b/golem_resource_pack_account/models/golem_resource_pack.py @@ -47,7 +47,7 @@ class GolemResourcePack(models.Model): if pack.state != 'validated': raise ValidationError(_('The current pack is not validated, please validate ' 'it before creating invoice')) - elif not pack.is_products_set: + elif not pack.are_products_set: raise ValidationError(_('You can not create an invoice for a pack without ' 'linked product on every resource reserved.')) elif pack.invoice_id.id: diff --git a/golem_resource_pack_account/tests/test_golem_pack_invoice.py b/golem_resource_pack_account/tests/test_golem_pack_invoice.py index 29961a5..9a882ad 100644 --- a/golem_resource_pack_account/tests/test_golem_pack_invoice.py +++ b/golem_resource_pack_account/tests/test_golem_pack_invoice.py @@ -80,6 +80,7 @@ class TestGolemResourcePack(TransactionCase): #set pack env self.pack_obj = self.env['golem.resource.pack'] self.pack_data = { + 'name': 'Pack test', 'partner_id': self.partner_1.id, 'reservation_ids': [(4, self.reservation_1.id, 0), (4, self.reservation_2.id, 0)]} From fb51cf9dc0f27856defe843343a146afdd2a4bdb Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 16 Apr 2018 19:18:12 +0200 Subject: [PATCH 42/50] [FIX]GOLEM Resource Account : keep reservation_id on invoice context, thanks Youssef for catching the bug --- .../wizard/golem_reservation_add_to_invoice_views.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml index 47a077b..dc9b433 100644 --- a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml @@ -27,7 +27,8 @@ along with this program. If not, see . - + From 0e20503a8b358e94d9932dab92e9921b8691661d Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Tue, 17 Apr 2018 08:57:08 +0200 Subject: [PATCH 43/50] [ADD]Updated translations for GOLEM Resources --- golem_resource/i18n/fr.po | 8 +- golem_resource_pack/i18n/fr.po | 209 +++++++++++++++++ .../i18n/golem_resource_pack.pot | 210 ++++++++++++++++++ golem_resource_pack_account/i18n/fr.po | 92 ++++++++ .../i18n/golem_resource_pack_account.pot | 89 ++++++++ 5 files changed, 604 insertions(+), 4 deletions(-) create mode 100644 golem_resource_pack/i18n/fr.po create mode 100644 golem_resource_pack/i18n/golem_resource_pack.pot create mode 100644 golem_resource_pack_account/i18n/fr.po create mode 100644 golem_resource_pack_account/i18n/golem_resource_pack_account.pot diff --git a/golem_resource/i18n/fr.po b/golem_resource/i18n/fr.po index bb80159..0e6090b 100644 --- a/golem_resource/i18n/fr.po +++ b/golem_resource/i18n/fr.po @@ -352,19 +352,19 @@ msgstr "Motif" #: model:ir.ui.view,arch_db:golem_resource.golem_reservation_rejection_wizard_view_form #: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_form msgid "Reject" -msgstr "Rejet" +msgstr "Refus" #. module: golem_resource #: selection:golem.resource.reservation,state:0 #: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_search msgid "Rejected" -msgstr "Rejeté" +msgstr "Refusé" #. module: golem_resource #: model:ir.model.fields,field_description:golem_resource.field_golem_resource_reservation_rejection_reason #: model:ir.ui.view,arch_db:golem_resource.golem_reservation_rejection_wizard_view_form msgid "Rejection reason" -msgstr "Motif du rejet" +msgstr "Motif du refus" #. module: golem_resource #: model:ir.ui.view,arch_db:golem_resource.golem_resource_reservation_view_form @@ -577,7 +577,7 @@ msgstr "Sans validation" #: code:addons/golem_resource/models/golem_resource_reservation.py:148 #, python-format msgid "You do not have permissions to validate or reject a reservation." -msgstr "Vous n'avez pas les autorisations nécessaires pour valider ou rejeter une réservation." +msgstr "Vous n'avez pas les autorisations nécessaires pour valider ou refuser une réservation." #. module: golem_resource #: model:ir.model,name:golem_resource.model_golem_reservation_rejection_wizard diff --git a/golem_resource_pack/i18n/fr.po b/golem_resource_pack/i18n/fr.po new file mode 100644 index 0000000..9e37567 --- /dev/null +++ b/golem_resource_pack/i18n/fr.po @@ -0,0 +1,209 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * golem_resource_pack +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-17 06:51+0000\n" +"PO-Revision-Date: 2018-04-17 06:51+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_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_pack_rejection_wizard_view_form +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Cancel" +msgstr "Annuler" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Canceled" +msgstr "Annulé" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Confirm" +msgstr "Confirmer" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Confirmed" +msgstr "Confirmé" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_create_uid +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_create_date +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_create_date +msgid "Created on" +msgstr "Créé le" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_display_name +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Draft" +msgstr "Brouillon" + +#. module: golem_resource_pack +#: model:ir.model,name:golem_resource_pack.model_golem_resource_reservation +msgid "GOLEM Reservation Model" +msgstr "GOLEM Reservation Model" + +#. module: golem_resource_pack +#: model:ir.model,name:golem_resource_pack.model_golem_resource_pack +msgid "GOLEM Resource Pack Model" +msgstr "GOLEM Resource Pack Model" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_id +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_id +msgid "ID" +msgstr "ID" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard___last_update +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack___last_update +msgid "Last Modified on" +msgstr "Dernière Modification le" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_write_uid +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_write_date +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_name +msgid "Name" +msgstr "Nom" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_note +msgid "Note" +msgstr "Note" + +#. module: golem_resource_pack +#: model:ir.model.fields,help:golem_resource_pack.field_golem_resource_pack_note +msgid "Notes, optional subject for the reservation, reason" +msgstr "Notes, subjet, motif, descriptif optionnel pour la réservation" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_partner_id +msgid "On behalf of" +msgstr "Pour le compte de" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Pack" +msgstr "Lot" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_pack_id +msgid "Pack id" +msgstr "Lot" + +#. module: golem_resource_pack +#: code:addons/golem_resource_pack/models/golem_resource_pack.py:126 +#, python-format +msgid "Pack partner should be the same for all reservations" +msgstr "Toutes les réservations devraient avoir le même compte" + +#. module: golem_resource_pack +#: code:addons/golem_resource_pack/models/golem_resource_pack.py:108 +#, python-format +msgid "Please enter the rejection reason" +msgstr "Merci de saisir le motif de refus" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_reason +msgid "Reason" +msgstr "Motif" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_pack_rejection_wizard_view_form +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Reject" +msgstr "Refus" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Rejected" +msgstr "Refusé" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_rejection_reason +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_pack_rejection_wizard_view_form +msgid "Rejection reason" +msgstr "Motif du refus" + +#. module: golem_resource_pack +#: model:ir.actions.act_window,name:golem_resource_pack.golem_resource_pack_action +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_reservation_pack_id +msgid "Reservation Pack" +msgstr "Lot de réservations" + +#. module: golem_resource_pack +#: model:ir.ui.menu,name:golem_resource_pack.golem_resource_packs_menu +msgid "Reservation Packs" +msgstr "Lots de réservations" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_reservation_count +msgid "Reservation count" +msgstr "Nombre de réservations" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_reservation_ids +msgid "Reservations" +msgstr "Réservations" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Set to draft" +msgstr "Brouillon" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_state +msgid "State" +msgstr "État" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_user_id +msgid "User" +msgstr "Utilisateur" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Validate" +msgstr "Valider" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Validated" +msgstr "Validé" + +#. module: golem_resource_pack +#: model:ir.model,name:golem_resource_pack.model_golem_pack_rejection_wizard +msgid "golem.pack.rejection.wizard" +msgstr "golem.pack.rejection.wizard" diff --git a/golem_resource_pack/i18n/golem_resource_pack.pot b/golem_resource_pack/i18n/golem_resource_pack.pot new file mode 100644 index 0000000..b8d7023 --- /dev/null +++ b/golem_resource_pack/i18n/golem_resource_pack.pot @@ -0,0 +1,210 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * golem_resource_pack +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-17 06:51+0000\n" +"PO-Revision-Date: 2018-04-17 06:51+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_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_pack_rejection_wizard_view_form +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Cancel" +msgstr "" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Canceled" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Confirm" +msgstr "" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Confirmed" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_create_uid +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_create_uid +msgid "Created by" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_create_date +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_create_date +msgid "Created on" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_display_name +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_display_name +msgid "Display Name" +msgstr "" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Draft" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model,name:golem_resource_pack.model_golem_resource_reservation +msgid "GOLEM Reservation Model" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model,name:golem_resource_pack.model_golem_resource_pack +msgid "GOLEM Resource Pack Model" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_id +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_id +msgid "ID" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard___last_update +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack___last_update +msgid "Last Modified on" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_write_uid +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_write_date +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_write_date +msgid "Last Updated on" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_name +msgid "Name" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_note +msgid "Note" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,help:golem_resource_pack.field_golem_resource_pack_note +msgid "Notes, optional subject for the reservation, reason" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_partner_id +msgid "On behalf of" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Pack" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_pack_id +msgid "Pack id" +msgstr "" + +#. module: golem_resource_pack +#: code:addons/golem_resource_pack/models/golem_resource_pack.py:126 +#, python-format +msgid "Pack partner should be the same for all reservations" +msgstr "" + +#. module: golem_resource_pack +#: code:addons/golem_resource_pack/models/golem_resource_pack.py:108 +#, python-format +msgid "Please enter the rejection reason" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_pack_rejection_wizard_reason +msgid "Reason" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_pack_rejection_wizard_view_form +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Reject" +msgstr "" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Rejected" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_rejection_reason +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_pack_rejection_wizard_view_form +msgid "Rejection reason" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.actions.act_window,name:golem_resource_pack.golem_resource_pack_action +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_reservation_pack_id +msgid "Reservation Pack" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.ui.menu,name:golem_resource_pack.golem_resource_packs_menu +msgid "Reservation Packs" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_reservation_count +msgid "Reservation count" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_reservation_ids +msgid "Reservations" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Set to draft" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_state +msgid "State" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model.fields,field_description:golem_resource_pack.field_golem_resource_pack_user_id +msgid "User" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.ui.view,arch_db:golem_resource_pack.golem_resource_pack_view_form +msgid "Validate" +msgstr "" + +#. module: golem_resource_pack +#: selection:golem.resource.pack,state:0 +msgid "Validated" +msgstr "" + +#. module: golem_resource_pack +#: model:ir.model,name:golem_resource_pack.model_golem_pack_rejection_wizard +msgid "golem.pack.rejection.wizard" +msgstr "" + diff --git a/golem_resource_pack_account/i18n/fr.po b/golem_resource_pack_account/i18n/fr.po new file mode 100644 index 0000000..ac45bb8 --- /dev/null +++ b/golem_resource_pack_account/i18n/fr.po @@ -0,0 +1,92 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * golem_resource_pack_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-17 06:51+0000\n" +"PO-Revision-Date: 2018-04-17 06:51+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_pack_account +#: model:ir.model.fields,help:golem_resource_pack_account.field_golem_resource_pack_invoice_state +msgid " * The 'Draft' status is used when a user is encoding a new and unconfirmed Invoice.\n" +" * The 'Pro-forma' status is used when the invoice does not have an invoice number.\n" +" * The 'Open' status is used when user creates invoice, an invoice number is generated. It stays in the open status till the user pays the invoice.\n" +" * The 'Paid' status is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled.\n" +" * The 'Cancelled' status is used when user cancel invoice." +msgstr "* L'état \"Brouillon\" est utilisé lorsqu'un utilisateur est en train de saisir ou de modifier une nouvelle facture non confirmée.\n" +"* L'état \"Pro-forma\" est utilisé lorsque la facture n'a pas de numéro de facture.\n" +"* L'état 'Ouvert' est utilisé lorsque l'utilisateur crée une facture, celle-ci a alors un numéro de facture. La facture reste dans l'état \"Ouvert\" tant qu'elle n'est pas payée.\n" +"* L'état 'Payé' est affecté automatiquement lorsque la facture est payée. Les écritures correspondantes dans les journaux peuvent ou non être lettrées.\n" +"* L'état \"Annulé\" est utilisé lorsque l'utilisateur annule la facture." + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_are_products_set +msgid "Are products set" +msgstr "Articles liés ?" + +#. module: golem_resource_pack_account +#: model:ir.ui.view,arch_db:golem_resource_pack_account.golem_resource_pack_inherit_account_form +msgid "Create Invoice" +msgstr "Créer une facture" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_currency_id +msgid "Currency" +msgstr "Devise" + +#. module: golem_resource_pack_account +#: model:ir.model,name:golem_resource_pack_account.model_golem_resource_pack +msgid "GOLEM Resource Pack Model" +msgstr "GOLEM Resource Pack Model" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_invoice_id +msgid "Invoice" +msgstr "Facture" + +#. module: golem_resource_pack_account +#: model:ir.ui.view,arch_db:golem_resource_pack_account.golem_resource_pack_inherit_account_form +msgid "Invoicing" +msgstr "Facturation" + +#. module: golem_resource_pack_account +#: model:ir.ui.view,arch_db:golem_resource_pack_account.golem_resource_pack_inherit_account_form +msgid "Show invoice" +msgstr "Voir la facture" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_invoice_state +msgid "Status" +msgstr "État" + +#. module: golem_resource_pack_account +#: code:addons/golem_resource_pack_account/models/golem_resource_pack.py:48 +#, python-format +msgid "The current pack is not validated, please validate it before creating invoice" +msgstr "Le lot actuel n'est pas validé, merci de le valider avant de pouvoir créer une facture" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_invoice_amount_total +msgid "Total" +msgstr "Total" + +#. module: golem_resource_pack_account +#: code:addons/golem_resource_pack_account/models/golem_resource_pack.py:54 +#, python-format +msgid "You can not create an invoice as there is already one." +msgstr "Vous ne pouvez pas créer une facture s'il y en a déjà une liée." + +#. module: golem_resource_pack_account +#: code:addons/golem_resource_pack_account/models/golem_resource_pack.py:51 +#, python-format +msgid "You can not create an invoice for a pack without linked product on every resource reserved." +msgstr "Vous ne pouvez pas créer une facture pour un lot sans article pour chacune des ressources liées aux réservations." diff --git a/golem_resource_pack_account/i18n/golem_resource_pack_account.pot b/golem_resource_pack_account/i18n/golem_resource_pack_account.pot new file mode 100644 index 0000000..d92cdc8 --- /dev/null +++ b/golem_resource_pack_account/i18n/golem_resource_pack_account.pot @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * golem_resource_pack_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-17 06:52+0000\n" +"PO-Revision-Date: 2018-04-17 06:52+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_pack_account +#: model:ir.model.fields,help:golem_resource_pack_account.field_golem_resource_pack_invoice_state +msgid " * The 'Draft' status is used when a user is encoding a new and unconfirmed Invoice.\n" +" * The 'Pro-forma' status is used when the invoice does not have an invoice number.\n" +" * The 'Open' status is used when user creates invoice, an invoice number is generated. It stays in the open status till the user pays the invoice.\n" +" * The 'Paid' status is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled.\n" +" * The 'Cancelled' status is used when user cancel invoice." +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_are_products_set +msgid "Are products set" +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.ui.view,arch_db:golem_resource_pack_account.golem_resource_pack_inherit_account_form +msgid "Create Invoice" +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_currency_id +msgid "Currency" +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.model,name:golem_resource_pack_account.model_golem_resource_pack +msgid "GOLEM Resource Pack Model" +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_invoice_id +msgid "Invoice" +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.ui.view,arch_db:golem_resource_pack_account.golem_resource_pack_inherit_account_form +msgid "Invoicing" +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.ui.view,arch_db:golem_resource_pack_account.golem_resource_pack_inherit_account_form +msgid "Show invoice" +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_invoice_state +msgid "Status" +msgstr "" + +#. module: golem_resource_pack_account +#: code:addons/golem_resource_pack_account/models/golem_resource_pack.py:48 +#, python-format +msgid "The current pack is not validated, please validate it before creating invoice" +msgstr "" + +#. module: golem_resource_pack_account +#: model:ir.model.fields,field_description:golem_resource_pack_account.field_golem_resource_pack_invoice_amount_total +msgid "Total" +msgstr "" + +#. module: golem_resource_pack_account +#: code:addons/golem_resource_pack_account/models/golem_resource_pack.py:54 +#, python-format +msgid "You can not create an invoice as there is already one." +msgstr "" + +#. module: golem_resource_pack_account +#: code:addons/golem_resource_pack_account/models/golem_resource_pack.py:51 +#, python-format +msgid "You can not create an invoice for a pack without linked product on every resource reserved." +msgstr "" + From 460d138730aa714e2282d8680b3151c2cd7af979 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Wed, 18 Apr 2018 17:50:05 +0200 Subject: [PATCH 44/50] [FIX]GOLEM Resource Pack : add name on form, as it is required --- golem_resource_pack/__manifest__.py | 2 +- golem_resource_pack/views/golem_resource_pack_views.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/golem_resource_pack/__manifest__.py b/golem_resource_pack/__manifest__.py index e88a8df..df0fe6c 100644 --- a/golem_resource_pack/__manifest__.py +++ b/golem_resource_pack/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM resources pack', 'summary': 'GOLEM resources pack', 'description': ''' GOLEM resources pack ''', - 'version': '10.0.0.0.4', + 'version': '10.0.0.0.5', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_resource_pack/views/golem_resource_pack_views.xml b/golem_resource_pack/views/golem_resource_pack_views.xml index f7a5e9b..096a3fb 100644 --- a/golem_resource_pack/views/golem_resource_pack_views.xml +++ b/golem_resource_pack/views/golem_resource_pack_views.xml @@ -57,6 +57,7 @@ along with this program. If not, see . + From 704e2809c2fea76e960cb563c3b5d550eb8fb4cf Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 25 May 2018 09:56:48 +0200 Subject: [PATCH 45/50] [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 46/50] [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 47/50] [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 48/50] [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 49/50] [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 50/50] [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)
- Date :
- On behalf of :
-
+ + + +
+ + - + + + + From
+ To +
+

+
+ For +

+
+
+