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,