From d620fb18b8e72d5ccce67908145e99cffcdbf0ec Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Sun, 18 Mar 2018 01:18:22 +0100 Subject: [PATCH] =?UTF-8?q?Affichage=20du=20facture=20apres=20sa=20cr?= =?UTF-8?q?=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 .