diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py
index cfa2b0d..e5209db 100644
--- a/golem_resource_account/models/golem_resource_reservation.py
+++ b/golem_resource_account/models/golem_resource_reservation.py
@@ -40,6 +40,9 @@ class GolemResourceReservation(models.Model):
def create_invoice(self):
""" Invoice creation """
for reservation in self:
+ if reservation.invoice_line_id:
+ raise ValidationError(_('You can not create an invoice as there '
+ 'is already one.'))
inv_obj = self.env['account.invoice']
partner_id = reservation.partner_id
product = reservation.resource_id.product_tmpl_id
@@ -66,11 +69,11 @@ class GolemResourceReservation(models.Model):
'invoice_line_ids': [(0, 0, {
'name': reservation.resource_id.name,
'origin': reservation.name,
- 'account_id': account_id,
'price_unit': amount,
'quantity': 1.0,
- 'discount': 0.0,
'uom_id': product.uom_id.id,
+ 'account_id': account_id,
'product_id': product.id,
- })]
- })
+ })]
+ })
+ reservation.invoice_line_id = reservation.invoice_id.invoice_line_ids[0]
diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml
index 00590f1..f25975b 100644
--- a/golem_resource_account/views/golem_resource_reservation_views.xml
+++ b/golem_resource_account/views/golem_resource_reservation_views.xml
@@ -28,6 +28,7 @@ along with this program. If not, see .
+
@@ -42,11 +43,10 @@ along with this program. If not, see .
attrs="{'invisible': [('invoice_id', '=', False)]}">