From fffc371f9661a51544918c30743a14633f0538ac Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 18 Mar 2013 16:30:49 +0100 Subject: [PATCH] [FIX] Fix wrong amounts in contract form and add grey text message in Create Invoice wizard bzr revid: jco@openerp.com-20130318153049-myvqzvv1c2zqgna8 --- .../analytic_contract_hr_expense.py | 13 ++++++++---- .../hr_timesheet_invoice_create_view.xml | 21 ++++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py b/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py index 254dad95c7d..8b10381434d 100644 --- a/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py +++ b/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py @@ -76,11 +76,11 @@ class account_analytic_account(osv.osv): GROUP BY product_id, user_id, to_invoice, product_uom_id, line.name""", (account.id,)) res[account.id] = 0.0 - for product_id, price, user_id, factor_id, qty, uom, line_name in cr.fetchall(): + for product_id, total_amount, user_id, factor_id, qty, uom, line_name in cr.fetchall(): #the amount to reinvoice is the real cost. We don't use the pricelist - price = -price + total_amount = -total_amount factor = self.pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context=context) - res[account.id] += price * qty * (100 - factor.factor or 0.0) / 100.0 + res[account.id] += total_amount * (100 - factor.factor or 0.0) / 100.0 return res def _expense_invoiced_calc(self, cr, uid, ids, name, arg, context=None): @@ -89,8 +89,13 @@ class account_analytic_account(osv.osv): for account in self.browse(cr, uid, ids, context=context): res[account.id] = 0.0 line_ids = lines_obj.search(cr, uid, [('account_id','=', account.id), ('invoice_id','!=',False), ('to_invoice','!=', False), ('journal_id.type', '=', 'purchase')], context=context) + #Put invoices in separate array in order not to calculate them double + invoices = [] for line in lines_obj.browse(cr, uid, line_ids, context=context): - res[account.id] += line.invoice_id.amount_untaxed + if line.invoice_id not in invoices: + invoices.append(line.invoice_id) + for invoice in invoices: + res[account.id] += invoice.amount_untaxed return res def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create_view.xml b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create_view.xml index 74d0fa1daf6..7d9f61c79ff 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create_view.xml +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create_view.xml @@ -9,16 +9,17 @@
- - - - - - - - - - + + + + + + + + + +

Beware that even if you don't force a product, the price on the expense is replaced by the sale price of the corresponding product if its sale price is not 0.

+