From 72739a2df64f59420ec842c72ef1a9f80a35f5ac Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Thu, 15 Mar 2018 17:28:21 +0100 Subject: [PATCH 01/38] Facturation individuel depuis reservation_form --- golem_resource_account/__init__.py | 19 ++++ golem_resource_account/__manifest__.py | 32 +++++++ golem_resource_account/models/__init__.py | 20 ++++ .../models/golem_resource_reservation.py | 66 +++++++++++++ golem_resource_account/tests/__init__.py | 17 ++++ .../golem_resource_reservation_views.xml | 96 +++++++++++++++++++ 6 files changed, 250 insertions(+) create mode 100644 golem_resource_account/__init__.py create mode 100644 golem_resource_account/__manifest__.py create mode 100644 golem_resource_account/models/__init__.py create mode 100644 golem_resource_account/models/golem_resource_reservation.py create mode 100644 golem_resource_account/tests/__init__.py create mode 100644 golem_resource_account/views/golem_resource_reservation_views.xml diff --git a/golem_resource_account/__init__.py b/golem_resource_account/__init__.py new file mode 100644 index 0000000..1fced20 --- /dev/null +++ b/golem_resource_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_account/__manifest__.py b/golem_resource_account/__manifest__.py new file mode 100644 index 0000000..d35b402 --- /dev/null +++ b/golem_resource_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 invoicing', + 'summary': 'GOLEM resources invoicing', + 'description': ''' GOLEM resources 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', + 'account'], + 'data': ['views/golem_resource_reservation_views.xml'] +} diff --git a/golem_resource_account/models/__init__.py b/golem_resource_account/models/__init__.py new file mode 100644 index 0000000..15dcb5c --- /dev/null +++ b/golem_resource_account/models/__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 golem_resource_reservation diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py new file mode 100644 index 0000000..848b99b --- /dev/null +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -0,0 +1,66 @@ +# -*- 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 math import modf +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError, UserError + + +class GolemResourceReservation(models.Model): + """ GOLEM Resource Reservation Adaptation """ + _inherit = 'golem.resource.reservation' + + + @api.multi + def create_invoice(self): + for reservation in self: + inv_obj = self.env['account.invoice'] + partner_id = reservation.partner_id + product = reservation.resource_id.product_tmpl_id + amount = product.standard_price + + if product.id: + account_id = product.property_account_income_id.id + if not account_id: + account_id = product.categ_id.property_account_income_categ_id.id + if not account_id: + raise UserError( + _('There is no income account defined for this product: "%s". \ + You may have to install a chart of account from Accounting \ + app, settings menu.') % (product.name,)) + + invoice = inv_obj.create({ + 'name': reservation.name, + #'origin': self.application_number, + 'type': 'out_invoice', + 'reference': False, + 'account_id': partner_id.property_account_receivable_id.id, + 'partner_id': partner_id.id, + 'invoice_line_ids': [(0, 0, { + 'name': reservation.resource_id.name, + #'origin': , + 'account_id': account_id, + 'price_unit': amount, + 'quantity': 1.0, + 'discount': 0.0, + 'uom_id': product.uom_id.id, + 'product_id': product.id, + })], + }) diff --git a/golem_resource_account/tests/__init__.py b/golem_resource_account/tests/__init__.py new file mode 100644 index 0000000..7d004f8 --- /dev/null +++ b/golem_resource_account/tests/__init__.py @@ -0,0 +1,17 @@ +# -*- 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 . diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml new file mode 100644 index 0000000..1f4af8a --- /dev/null +++ b/golem_resource_account/views/golem_resource_reservation_views.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + GOLEM Resource Reservation Form Adaptations to invoicing + golem.resource.reservation + + + + + + + + + + + + + + + + + From c3f7ee1bb434f94dc4f8b7672bf18b94795b6735 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 16 Mar 2018 16:04:33 +0100 Subject: [PATCH 02/38] Ajout du Facturation multi ligne depuis action --- golem_resource_account/__init__.py | 2 +- golem_resource_account/__manifest__.py | 5 +- .../models/golem_resource_reservation.py | 5 +- .../golem_resource_reservation_views.xml | 19 +++++ golem_resource_account/wizard/__init__.py | 20 +++++ .../wizard/golem_reservation_invoice.py | 78 ++++++++++++++++++ .../wizard/golem_reservation_invoice.xml | 79 +++++++++++++++++++ 7 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 golem_resource_account/wizard/__init__.py create mode 100644 golem_resource_account/wizard/golem_reservation_invoice.py create mode 100644 golem_resource_account/wizard/golem_reservation_invoice.xml diff --git a/golem_resource_account/__init__.py b/golem_resource_account/__init__.py index 1fced20..f95e908 100644 --- a/golem_resource_account/__init__.py +++ b/golem_resource_account/__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_account/__manifest__.py b/golem_resource_account/__manifest__.py index d35b402..7451bd4 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.0.0', + 'version': '10.0.0.0.2', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', @@ -28,5 +28,6 @@ 'installable': True, 'depends': ['golem_resource', 'account'], - 'data': ['views/golem_resource_reservation_views.xml'] + 'data': ['views/golem_resource_reservation_views.xml', + 'wizard/golem_reservation_invoice.xml'] } diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 848b99b..ca8baa5 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -27,7 +27,7 @@ class GolemResourceReservation(models.Model): """ GOLEM Resource Reservation Adaptation """ _inherit = 'golem.resource.reservation' - + @api.multi def create_invoice(self): for reservation in self: @@ -38,13 +38,16 @@ class GolemResourceReservation(models.Model): if product.id: account_id = product.property_account_income_id.id + if not account_id: account_id = product.categ_id.property_account_income_categ_id.id + if not account_id: raise UserError( _('There is no income account defined for this product: "%s". \ You may have to install a chart of account from Accounting \ app, settings menu.') % (product.name,)) + invoice = inv_obj.create({ 'name': reservation.name, diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml index 1f4af8a..809edbf 100644 --- a/golem_resource_account/views/golem_resource_reservation_views.xml +++ b/golem_resource_account/views/golem_resource_reservation_views.xml @@ -82,6 +82,25 @@ along with this program. If not, see . --> + + + + + + + + + + + + + + GOLEM Reservation Invoice Wizard Form Editable + golem.reservation.invoice.wizard + +
+ + + +
+
+
+
+
+ + + GOLEM Reservation Invoice Wizard Form + golem.reservation.invoice.wizard + +
+
+
+ + + + +
+
From 5b7627f667de96e96bbd7f5b1536e0b867999ef8 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Fri, 16 Mar 2018 16:13:18 +0100 Subject: [PATCH 03/38] =?UTF-8?q?quelque=20modification=20non=20termin?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- golem_resource_account/models/golem_resource_reservation.py | 5 ++++- .../views/golem_resource_reservation_views.xml | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index ca8baa5..bb6cef7 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -27,6 +27,9 @@ class GolemResourceReservation(models.Model): """ GOLEM Resource Reservation Adaptation """ _inherit = 'golem.resource.reservation' + invoice_id = fields.Many2one('account.invoice') + invoice_state = fields.Selection(related="invoice_id.state") + @api.multi def create_invoice(self): @@ -47,7 +50,7 @@ class GolemResourceReservation(models.Model): _('There is no income account defined for this product: "%s". \ You may have to install a chart of account from Accounting \ app, settings menu.') % (product.name,)) - + invoice = inv_obj.create({ 'name': reservation.name, diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml index 809edbf..a1add3a 100644 --- a/golem_resource_account/views/golem_resource_reservation_views.xml +++ b/golem_resource_account/views/golem_resource_reservation_views.xml @@ -22,8 +22,8 @@ along with this program. If not, see . - + Date: Sat, 17 Mar 2018 16:23:39 +0100 Subject: [PATCH 05/38] =?UTF-8?q?filtrage=20du=20statut=20de=20facturation?= =?UTF-8?q?=20et=20fonction=20de=20search=20sur=20le=20champs=20calcul?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/golem_resource_reservation.py | 43 +++++++++++++++++-- .../golem_resource_reservation_views.xml | 30 ++++++------- .../wizard/golem_reservation_invoice.py | 3 +- 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 0b774a7..393e14b 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -28,7 +28,44 @@ class GolemResourceReservation(models.Model): _inherit = 'golem.resource.reservation' invoice_id = fields.Many2one('account.invoice') - invoicing_state = fields.Selection(related="invoice_id.state", string="Invoicing Status", default="None") + invoicing_state = fields.Char(compute="_compute_invoicing_state", + search='_search_invoicing_state', + string="Invoicing Status", + default="None") + + def _search_invoicing_state(self, operator, value): + if value == "None": + reservation = self.env['golem.resource.reservation'].search([('invoice_id', '=', False)]) + return [('id', 'in', reservation.mapped('id'))] + else: + return [('invoice_id.state', operator, value)] + + + """ + print '________________________________' + print("kelri") + + if self.invoice_id: + invoicing_state = self.invoice_id.state + print "_____________________1" + print invoicing_state + return [('invoicing_state', operator, value)] + else: + invoicing_state = "None" + print '_____________________2' + print invoicing_state + return [('invoicing_state', operator, value)] + print invoicing_state + """ + @api.multi + @api.depends('invoice_id') + def _compute_invoicing_state(self): + """ Compute invoicing_state """ + for reservation in self: + if reservation.invoice_id: + reservation.invoicing_state = reservation.invoice_id.state + else: + reservation.invoicing_state = "None" @api.multi @@ -38,7 +75,7 @@ class GolemResourceReservation(models.Model): partner_id = reservation.partner_id product = reservation.resource_id.product_tmpl_id amount = product.standard_price - + quantity = reservation.hour_stop - reservation.hour_start if product.id: account_id = product.property_account_income_id.id @@ -64,7 +101,7 @@ class GolemResourceReservation(models.Model): #'origin': , 'account_id': account_id, 'price_unit': amount, - 'quantity': 1.0, + 'quantity': quantity, 'discount': 0.0, 'uom_id': product.uom_id.id, 'product_id': product.id, diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml index 8741857..4999ede 100644 --- a/golem_resource_account/views/golem_resource_reservation_views.xml +++ b/golem_resource_account/views/golem_resource_reservation_views.xml @@ -48,20 +48,22 @@ along with this program. If not, see . - --> @@ -84,7 +86,6 @@ along with this program. If not, see . res_model="golem.reservation.invoice.wizard" src_model="golem.resource.reservation" view_mode="form" - view_id="golem_reservation_invoice_wizard_form" multi="True" target="new" /> @@ -93,7 +94,6 @@ along with this program. If not, see . res_model="golem.reservation.invoice.wizard" src_model="golem.resource.reservation" view_mode="form" - view_id="golem_reservation_invoice_wizard_form_editable" multi="True" target="new" /> diff --git a/golem_resource_account/wizard/golem_reservation_invoice.py b/golem_resource_account/wizard/golem_reservation_invoice.py index 51269eb..8afb0ec 100644 --- a/golem_resource_account/wizard/golem_reservation_invoice.py +++ b/golem_resource_account/wizard/golem_reservation_invoice.py @@ -57,12 +57,13 @@ class GolemReservationInvoiceWizard(models.TransientModel): for reservation in self.reservation_ids: product = reservation.resource_id.product_tmpl_id amount = product.standard_price + quantity = reservation.hour_stop - reservation.hour_start lines.append((0, 0, { 'name': reservation.resource_id.name, #'origin': , 'account_id': account_id, 'price_unit': amount, - 'quantity': 1.0, + 'quantity': quantity, 'discount': 0.0, 'uom_id': product.uom_id.id, 'product_id': product.id, From d620fb18b8e72d5ccce67908145e99cffcdbf0ec Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Sun, 18 Mar 2018 01:18:22 +0100 Subject: [PATCH 06/38] =?UTF-8?q?Affichage=20du=20facture=20apres=20sa=20c?= =?UTF-8?q?r=C3=A9ation,=20automatiquemet=20et=20via=20bouton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/golem_resource_reservation.py | 30 +++++++------------ .../golem_resource_reservation_views.xml | 10 +++++-- .../wizard/golem_reservation_invoice.py | 8 +++++ .../wizard/golem_reservation_invoice.xml | 4 +++ 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 393e14b..a91c4c7 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -39,24 +39,7 @@ class GolemResourceReservation(models.Model): return [('id', 'in', reservation.mapped('id'))] else: return [('invoice_id.state', operator, value)] - - """ - print '________________________________' - print("kelri") - - if self.invoice_id: - invoicing_state = self.invoice_id.state - print "_____________________1" - print invoicing_state - return [('invoicing_state', operator, value)] - else: - invoicing_state = "None" - print '_____________________2' - print invoicing_state - return [('invoicing_state', operator, value)] - print invoicing_state - """ @api.multi @api.depends('invoice_id') def _compute_invoicing_state(self): @@ -67,6 +50,17 @@ class GolemResourceReservation(models.Model): else: reservation.invoicing_state = "None" + @api.multi + def voir_invoice(self): + for reservation in self: + if reservation.invoice_id: + return {'name' : _('Reservation Invoice'), + 'type' : 'ir.actions.act_window', + 'res_model' : 'account.invoice', + 'res_id' : reservation.invoice_id.id, + 'view_mode': 'form', + 'target': 'current'} + @api.multi def create_invoice(self): @@ -87,8 +81,6 @@ class GolemResourceReservation(models.Model): _('There is no income account defined for this product: "%s". \ You may have to install a chart of account from Accounting \ app, settings menu.') % (product.name,)) - - reservation.invoice_id = inv_obj.create({ 'name': reservation.name, #'origin': self.application_number, diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml index 4999ede..a4e742e 100644 --- a/golem_resource_account/views/golem_resource_reservation_views.xml +++ b/golem_resource_account/views/golem_resource_reservation_views.xml @@ -41,9 +41,15 @@ along with this program. If not, see . + + + diff --git a/golem_resource_account/wizard/golem_reservation_invoice.py b/golem_resource_account/wizard/golem_reservation_invoice.py index 8afb0ec..27a02e8 100644 --- a/golem_resource_account/wizard/golem_reservation_invoice.py +++ b/golem_resource_account/wizard/golem_reservation_invoice.py @@ -78,3 +78,11 @@ class GolemReservationInvoiceWizard(models.TransientModel): 'invoice_line_ids': lines, }) self.reservation_ids.write({'invoice_id': invoice.id}) + if self._context.get('open_invoices', False): + return {'name' : _('Reservation Invoice'), + 'type' : 'ir.actions.act_window', + 'res_model' : 'account.invoice', + 'res_id' : invoice.id, + 'view_mode': 'form', + 'target': 'current'} + return {'type': 'ir.actions.act_window_close'} diff --git a/golem_resource_account/wizard/golem_reservation_invoice.xml b/golem_resource_account/wizard/golem_reservation_invoice.xml index 2b724a0..365746f 100644 --- a/golem_resource_account/wizard/golem_reservation_invoice.xml +++ b/golem_resource_account/wizard/golem_reservation_invoice.xml @@ -48,6 +48,8 @@ along with this program. If not, see .