diff --git a/golem_resource_account/__manifest__.py b/golem_resource_account/__manifest__.py index 3560e1b..50e5cfb 100644 --- a/golem_resource_account/__manifest__.py +++ b/golem_resource_account/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM resources invoicing', 'summary': 'GOLEM resources invoicing', 'description': ''' GOLEM resources invoicing ''', - 'version': '10.0.0.2.0', + 'version': '10.0.0.3.0', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index 94b35ac..ed92997 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -75,11 +75,13 @@ class GolemResourceReservation(models.Model): product.categ_id.property_account_income_categ_id.id delta = fields.Datetime.from_string(reservation.date_stop) - \ fields.Datetime.from_string(reservation.date_start) - quantity = 1 - if product.uom_id.name == 'Hour(s)' or product.uom_id.name == 'Unit(s)': - quantity = int((delta.days * 24) + (delta.seconds/3600.0)) - elif product.uom_id.name == 'Day(s)': - quantity = int(delta.days + (delta.seconds/86400.0))#number of seconds in a day + quantity = 1.0 + # Make quantity coherent with UoM + if product.uom_id in (self.env.ref('product.product_uom_hour'), + self.env.ref('product.product_uom_unit')): + quantity = int(round((delta.days * 24.0) + (delta.seconds/3600.0))) + elif product.uom_id == self.env.ref('product.product_uom_day'): + quantity = int(round(delta.days + (delta.seconds/86400.0))) line_id = self.env['account.invoice.line'].create({ 'invoice_id': invoice_id.id, 'name': product.name,