From 9b25450a4a6118bab2b17ec411762dad4a8e2407 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 26 Mar 2018 16:22:57 +0200 Subject: [PATCH] [MOV][QUA]Pure quality / renaming --- golem_resource_account/__manifest__.py | 2 +- .../golem_resource_reservation_views.xml | 29 +++---- .../wizard/golem_reservation_invoice.py | 79 +++++++++---------- ...ml => golem_reservation_invoice_views.xml} | 29 ++----- 4 files changed, 55 insertions(+), 84 deletions(-) rename golem_resource_account/wizard/{golem_reservation_invoice.xml => golem_reservation_invoice_views.xml} (72%) diff --git a/golem_resource_account/__manifest__.py b/golem_resource_account/__manifest__.py index 5296b87..2ebd21b 100644 --- a/golem_resource_account/__manifest__.py +++ b/golem_resource_account/__manifest__.py @@ -27,6 +27,6 @@ 'application': True, 'installable': True, 'depends': ['golem_resource', 'account'], - 'data': ['wizard/golem_reservation_invoice.xml', + 'data': ['wizard/golem_reservation_invoice_views.xml', 'views/golem_resource_reservation_views.xml'] } diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml index acf7021..dd83272 100644 --- a/golem_resource_account/views/golem_resource_reservation_views.xml +++ b/golem_resource_account/views/golem_resource_reservation_views.xml @@ -95,26 +95,15 @@ along with this program. If not, see . view_mode="form" view_id="golem_reservation_invoice_wizard_form" multi="True" - target="new" - /> - - - - - - - + target="new" /> + diff --git a/golem_resource_account/wizard/golem_reservation_invoice.py b/golem_resource_account/wizard/golem_reservation_invoice.py index 5980a80..056a623 100644 --- a/golem_resource_account/wizard/golem_reservation_invoice.py +++ b/golem_resource_account/wizard/golem_reservation_invoice.py @@ -26,52 +26,51 @@ class GolemReservationInvoiceWizard(models.TransientModel): """ GOLEM Resource Reservation Invoice Wizard """ _name = 'golem.reservation.invoice.wizard' - reservation_ids = fields.Many2many('golem.resource.reservation', - default=lambda self: self._context.get('active_ids', []), - string='Reservations to invoice') + reservation_ids = fields.Many2many( + 'golem.resource.reservation', required=True, string='Reservations to invoice', + default=lambda self: self._context.get('active_ids', [])) @api.multi def create_invoices(self): """ Invoice creations """ self.ensure_one() - if self.reservation_ids: - inv_obj = self.env['account.invoice'] - partner_id = self.reservation_ids[0].partner_id - product = self.reservation_ids[0].resource_id.product_tmpl_id + inv_obj = self.env['account.invoice'] + partner_id = self.reservation_ids[0].partner_id + product = self.reservation_ids[0].resource_id.product_tmpl_id - 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,)) + 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,)) - lines = [] + lines = [] - for reservation in self.reservation_ids: - product = reservation.resource_id.product_tmpl_id - amount = product.standard_price - lines.append((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, - })) - invoice = inv_obj.create({ - 'name': self.reservation_ids[-1].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': lines, - }) - self.reservation_ids.write({'invoice_id': invoice.id}) + for reservation in self.reservation_ids: + product = reservation.resource_id.product_tmpl_id + amount = product.standard_price + lines.append((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, + })) + invoice = inv_obj.create({ + 'name': self.reservation_ids[-1].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': lines, + }) + self.reservation_ids.write({'invoice_id': invoice.id}) diff --git a/golem_resource_account/wizard/golem_reservation_invoice.xml b/golem_resource_account/wizard/golem_reservation_invoice_views.xml similarity index 72% rename from golem_resource_account/wizard/golem_reservation_invoice.xml rename to golem_resource_account/wizard/golem_reservation_invoice_views.xml index 2b724a0..caa74e9 100644 --- a/golem_resource_account/wizard/golem_reservation_invoice.xml +++ b/golem_resource_account/wizard/golem_reservation_invoice_views.xml @@ -19,24 +19,6 @@ along with this program. If not, see . - - - - - @@ -45,7 +27,7 @@ along with this program. If not, see .
- +