diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 76aba5312ed..0d51c95e64e 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -432,22 +432,20 @@ class account_analytic_account(osv.osv): 'toinvoice_total' : fields.function(_sum_of_fields, type="float",multi="sum_of_all"), } - def on_change_template(self, cr, uid, id, template_id): + def on_change_template(self, cr, uid, id, template_id, context=None): if not template_id: return {} res = {'value':{}} - template = self.browse(cr, uid, template_id) + template = self.browse(cr, uid, template_id, context=context) if template.date_start: res['value']['date_start'] = str(template.date_start) if template.date: res['value']['date'] = str(template.date) res['value']['fix_price_invoices'] = template.fix_price_invoices res['value']['invoice_on_timesheets'] = template.invoice_on_timesheets - res['value']['charge_expenses'] = template.charge_expenses res['value']['quantity_max'] = template.quantity_max res['value']['remaining_hours'] = template.remaining_hours res['value']['amount_max'] = template.amount_max - res['value']['expense_max'] = template.expense_max res['value']['to_invoice'] = template.to_invoice.id res['value']['pricelist_id'] = template.pricelist_id.id res['value']['description'] = template.description 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 87878090777..0fff5f1d7bd 100644 --- a/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py +++ b/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py @@ -117,6 +117,14 @@ class account_analytic_account(osv.osv): 'est_expenses': fields.float('Estimation of Expenses to Invoice'), } + def on_change_template(self, cr, uid, id, template_id, context=None): + res = super(account_analytic_account, self).on_change_template(cr, uid, id, template_id, context=context) + if template_id and 'value' in res: + template = self.browse(cr, uid, template_id, context=context) + res['value']['charge_expenses'] = template.charge_expenses + res['value']['expense_max'] = template.expense_max + return res + def open_hr_expense(self, cr, uid, ids, context=None): account = self.browse(cr, uid, ids[0], context) data_obj = self.pool.get('ir.model.data')