diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py
index a91c4c7..9681a7e 100644
--- a/golem_resource_account/models/golem_resource_reservation.py
+++ b/golem_resource_account/models/golem_resource_reservation.py
@@ -20,7 +20,7 @@
from odoo import models, fields, api, _
-from odoo.exceptions import ValidationError, UserError
+from odoo.exceptions import UserError
class GolemResourceReservation(models.Model):
@@ -35,7 +35,8 @@ class GolemResourceReservation(models.Model):
def _search_invoicing_state(self, operator, value):
if value == "None":
- reservation = self.env['golem.resource.reservation'].search([('invoice_id', '=', False)])
+ reservation = self.env['golem.resource.reservation'].search(
+ [('invoice_id', '=', False)])
return [('id', 'in', reservation.mapped('id'))]
else:
return [('invoice_id.state', operator, value)]
@@ -51,7 +52,8 @@ class GolemResourceReservation(models.Model):
reservation.invoicing_state = "None"
@api.multi
- def voir_invoice(self):
+ def open_invoice(self):
+ """ open invoice """
for reservation in self:
if reservation.invoice_id:
return {'name' : _('Reservation Invoice'),
@@ -59,11 +61,13 @@ class GolemResourceReservation(models.Model):
'res_model' : 'account.invoice',
'res_id' : reservation.invoice_id.id,
'view_mode': 'form',
+ 'view_id': self.env.ref('account.invoice_form').id,
'target': 'current'}
@api.multi
def create_invoice(self):
+ """ Create invoice """
for reservation in self:
inv_obj = self.env['account.invoice']
partner_id = reservation.partner_id
@@ -81,9 +85,9 @@ 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({
+ invoice = inv_obj.create({
'name': reservation.name,
- #'origin': self.application_number,
+ 'origin': reservation.name,
'type': 'out_invoice',
'reference': False,
'account_id': partner_id.property_account_receivable_id.id,
@@ -99,3 +103,4 @@ class GolemResourceReservation(models.Model):
'product_id': product.id,
})],
})
+ reservation.invoice_id = invoice.id
diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml
index a4e742e..695be26 100644
--- a/golem_resource_account/views/golem_resource_reservation_views.xml
+++ b/golem_resource_account/views/golem_resource_reservation_views.xml
@@ -18,9 +18,6 @@ along with this program. If not, see .
-->
-
-
-
GOLEM Resource Reservation Tree Adaptation to invoicing
@@ -44,7 +41,7 @@ along with this program. If not, see .
-
@@ -69,20 +66,6 @@ along with this program. If not, see .
domain="[('invoicing_state', '=', 'open')]" />
-
-->
@@ -95,23 +78,5 @@ along with this program. If not, see .
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 27a02e8..1a2971f 100644
--- a/golem_resource_account/wizard/golem_reservation_invoice.py
+++ b/golem_resource_account/wizard/golem_reservation_invoice.py
@@ -30,11 +30,9 @@ class GolemReservationInvoiceWizard(models.TransientModel):
default=lambda self: self._context.get('active_ids', []),
string='Reservations to invoice')
-
-
-
@api.multi
def create_invoices(self):
+ """ Create invoices for reservation """
self.ensure_one()
if self.reservation_ids:
@@ -55,6 +53,11 @@ class GolemReservationInvoiceWizard(models.TransientModel):
lines = []
for reservation in self.reservation_ids:
+ if partner_id != reservation.partner_id:
+ raise ValidationError(
+ _("You can't group reservations of multiple clients in the same \
+ invoice, please remove inadequate reservations"))
+
product = reservation.resource_id.product_tmpl_id
amount = product.standard_price
quantity = reservation.hour_stop - reservation.hour_start
@@ -69,8 +72,8 @@ class GolemReservationInvoiceWizard(models.TransientModel):
'product_id': product.id,
}))
invoice = inv_obj.create({
- 'name': reservation.name,
- #'origin': self.application_number,
+ #'name': reservation.name,
+ #'origin': ,
'type': 'out_invoice',
'reference': False,
'account_id': partner_id.property_account_receivable_id.id,
@@ -84,5 +87,6 @@ class GolemReservationInvoiceWizard(models.TransientModel):
'res_model' : 'account.invoice',
'res_id' : invoice.id,
'view_mode': 'form',
+ 'view_id': self.env.ref('account.invoice_form').id,
'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 365746f..a73779b 100644
--- a/golem_resource_account/wizard/golem_reservation_invoice.xml
+++ b/golem_resource_account/wizard/golem_reservation_invoice.xml
@@ -18,46 +18,7 @@ along with this program. If not, see .
-->
-
-
-
-
-
-
-
- GOLEM Reservation Invoice Wizard Form Editable
- golem.reservation.invoice.wizard
-
-
-
-
-
GOLEM Reservation Invoice Wizard Form
@@ -65,6 +26,7 @@ along with this program. If not, see .
-
-
-
-