From e36c9b537cced9c25042e3c46c9141fc98879498 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 28 Mar 2018 16:57:56 +0200 Subject: [PATCH 01/25] =?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/25] 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/25] 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/25] =?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/25] =?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/25] 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/25] =?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/25] 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/25] 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/25] 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/25] 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 b105d877459897a138101e3fd01e0a85ec1fb192 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Mon, 16 Apr 2018 18:04:05 +0200 Subject: [PATCH 13/25] code refactoring --- golem_resource_pack/models/golem_resource_pack.py | 4 +++- golem_resource_pack/models/golem_resource_reservation.py | 5 +---- golem_resource_pack/tests/test_golem_resource_pack.py | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/golem_resource_pack/models/golem_resource_pack.py b/golem_resource_pack/models/golem_resource_pack.py index fa176e5..ad51f7e 100644 --- a/golem_resource_pack/models/golem_resource_pack.py +++ b/golem_resource_pack/models/golem_resource_pack.py @@ -35,7 +35,7 @@ class GolemResourcePack(models.Model): False : [('readonly', False)]}) note = fields.Text(help='Notes, optional subject for the reservation, reason', - track_visibility='onchange',readonly=True, + track_visibility='onchange', readonly=True, states={'draft': [('readonly', False)], False : [('readonly', False)]}) @@ -59,6 +59,7 @@ class GolemResourcePack(models.Model): @api.multi @api.constrains('partner_id') def set_reservation_partner(self): + """ Set reservation partner """ for pack in self: pack.reservation_ids.write({'partner_id': pack.partner_id.id}) @@ -114,6 +115,7 @@ class GolemResourcePack(models.Model): @api.multi @api.constrains('reservation_ids') def check_reservation_partner(self): + """ Check reservation partner """ 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')) diff --git a/golem_resource_pack/models/golem_resource_reservation.py b/golem_resource_pack/models/golem_resource_reservation.py index bf4c7c6..2644175 100644 --- a/golem_resource_pack/models/golem_resource_reservation.py +++ b/golem_resource_pack/models/golem_resource_reservation.py @@ -18,10 +18,7 @@ """ GOLEM Resource Reservation """ -from math import modf -from datetime import timedelta -from odoo import models, fields, api, _ -from odoo.exceptions import ValidationError +from odoo import models, fields class GolemResourceReservation(models.Model): diff --git a/golem_resource_pack/tests/test_golem_resource_pack.py b/golem_resource_pack/tests/test_golem_resource_pack.py index e824749..1cc5274 100644 --- a/golem_resource_pack/tests/test_golem_resource_pack.py +++ b/golem_resource_pack/tests/test_golem_resource_pack.py @@ -20,7 +20,6 @@ import logging from odoo.tests.common import TransactionCase -from odoo.exceptions import ValidationError _LOGGER = logging.getLogger(__name__) @@ -102,7 +101,7 @@ class TestGolemResourcePack(TransactionCase): 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)] + pack.reservation_ids = [(5, 0, 0)] self.assertFalse(pack.reservation_ids) self.assertEqual(pack.reservation_count, 0) From 482e4c0b694d79e3f5def95fe62d8658dc92bc2f Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Tue, 3 Apr 2018 12:33:31 +0200 Subject: [PATCH 14/25] 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 b584cf8bef718357570087d0a2be4251763c3952 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 4 Apr 2018 17:57:01 +0200 Subject: [PATCH 15/25] 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 16/25] =?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 17/25] [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 18/25] [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 19/25] [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 24/25] [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 25/25] [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 . - +