From d409c1be456eec1836c77da5ccd6b8dce8721d1d Mon Sep 17 00:00:00 2001 From: ced <> Date: Fri, 12 Oct 2007 10:53:47 +0000 Subject: [PATCH] Fix invoice on timesheet wizard when there is no invoice rate bzr revid: ced-097a471a1db1c691b856225beb8d85d2517ed6d7 --- .../wizard/hr_timesheet_final_invoice_create.py | 11 ++++++----- .../wizard/hr_timesheet_invoice_create.py | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py index 149050a6298..da10281c5c5 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py @@ -86,11 +86,12 @@ class final_invoice_create(wizard.interface): context2=context.copy() context2['lang'] = partner.lang - cr.execute("SELECT product_id, to_invoice, sum(unit_amount) \ - FROM account_analytic_line as line \ - WHERE account_id = %d AND to_invoice IS NOT NULL \ - GROUP BY product_id, to_invoice", (account.id,)) - for product_id, factor_id, qty in cr.fetchall(): + cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ + "FROM account_analytic_line as line " \ + "WHERE account_id = %d " \ + "AND to_invoice IS NOT NULL " \ + "GROUP BY product_id, to_invoice", (account.id,)) + for product_id,factor_id,qty in cr.fetchall(): product = pool.get('product.product').browse(cr, uid, product_id, context2) factor_name = '' factor = pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context2) diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py index 686d7c6a0bd..8842e3127ab 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -88,12 +88,13 @@ class invoice_create(wizard.interface): context2=context.copy() context2['lang'] = partner.lang - cr.execute("SELECT product_id, to_invoice, sum(unit_amount) \ - FROM account_analytic_line as line \ - WHERE account_id = %d AND id IN ("+','.join(map(str,data['ids']))+") \ - AND to_invoice IS NOT NULL \ - GROUP BY product_id, to_invoice", (account.id,)) - for product_id, factor_id, qty in cr.fetchall(): + cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ + "FROM account_analytic_line as line " \ + "WHERE account_id = %d " \ + "AND id IN (" + ','.join([str(x) for x in data['ids']]) + ") " \ + "AND to_invoice IS NOT NULL " \ + "GROUP BY product_id,to_invoice", (account.id,)) + for product_id,factor_id,qty in cr.fetchall(): product = pool.get('product.product').browse(cr, uid, product_id, context2) if not product: raise wizard.except_wizard('Error', 'At least on line have no product !')