From 58a9ccd223e37c902c3cfab28955a4437d0db492 Mon Sep 17 00:00:00 2001 From: "Anup (OpenERP)" Date: Tue, 19 Apr 2011 13:01:35 +0530 Subject: [PATCH] [FIX] product,hr_timesheet_invoice : Invoicing analytic lines(timesheet lines) were calculating wrong prices for product (Support SaaS Case : 5267) bzr revid: ach@tinyerp.com-20110419073135-az6tvqgfbepkr94c --- .../wizard/hr_timesheet_invoice_create.py | 12 +++++++----- addons/product/pricelist.py | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) 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 f3f720687cf..63d1b3d66f8 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -108,13 +108,13 @@ class hr_timesheet_invoice_create(osv.osv_memory): context2 = context.copy() context2['lang'] = partner.lang - cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ + cr.execute("SELECT product_id, to_invoice, sum(unit_amount),product_uom_id " \ "FROM account_analytic_line as line " \ "WHERE account_id = %s " \ "AND id IN %s AND to_invoice IS NOT NULL " \ - "GROUP BY product_id,to_invoice", (account.id, tuple(context['active_ids']),)) + "GROUP BY product_id,to_invoice,product_uom_id", (account.id, tuple(context['active_ids']),)) - for product_id, factor_id, qty in cr.fetchall(): + for product_id, factor_id, qty, uom in cr.fetchall(): product = product_obj.browse(cr, uid, product_id, context2) if not product: raise osv.except_osv(_('Error'), _('At least one line has no product !')) @@ -129,9 +129,11 @@ class hr_timesheet_invoice_create(osv.osv_memory): else: factor_name = product_obj.name_get(cr, uid, [data['product']], context=context)[0][1] + ctx = context.copy() + ctx.update({'uom':uom}) if account.pricelist_id: pl = account.pricelist_id.id - price = pro_price_obj.price_get(cr,uid,[pl], data['product'] or product_id, qty or 1.0, account.partner_id.id)[pl] + price = pro_price_obj.price_get(cr,uid,[pl], data['product'] or product_id, qty or 1.0, account.partner_id.id, context=ctx)[pl] else: price = 0.0 @@ -147,7 +149,7 @@ class hr_timesheet_invoice_create(osv.osv_memory): 'name': factor_name, 'product_id': data['product'] or product_id, 'invoice_line_tax_id': [(6,0,tax)], - 'uos_id': product.uom_id.id, + 'uos_id': uom, 'account_id': account_id, 'account_analytic_id': account.id, } diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index f52ad20bba3..2c9db54f0a3 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -265,6 +265,9 @@ class product_pricelist(osv.osv): price_type.currency_id.id, res['currency_id'], product_obj.price_get(cr, uid, [product_id], price_type.field,context=context)[product_id], round=False, context=context) + + if 'uom' in context: + uom_price_already_computed = True if price is not False: price_limit = price