[IMP]GOLEM Resource Account : better coherence for quantities and UoM, using XMLIDS

This commit is contained in:
Fabien BOURGEOIS 2018-05-25 17:41:27 +02:00
parent c89cc9a2ed
commit 1a66cbd81c
2 changed files with 8 additions and 6 deletions

View File

@ -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',

View File

@ -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,