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 8f1ef4ef261..6263498d126 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 @@ -93,7 +93,7 @@ class final_invoice_create(osv.osv_memory): last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context) invoices.append(last_invoice) - context2=context.copy() + context2 = context.copy() context2['lang'] = partner.lang cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ "FROM account_analytic_line as line " \ 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..20c4161cf3b 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..f5c58f6e772 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -266,6 +266,8 @@ class product_pricelist(osv.osv): product_obj.price_get(cr, uid, [product_id], price_type.field,context=context)[product_id], round=False, context=context) + uom_price_already_computed = True + if price is not False: price_limit = price