[IMP] analytic_contract_hr_expense: replay of previous commit (removed during merge...
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Thu, 7 Jun 2012 12:45:20 +0000 (14:45 +0200)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Thu, 7 Jun 2012 12:45:20 +0000 (14:45 +0200)
bzr revid: qdp-launchpad@openerp.com-20120607124520-s8irgxvg4s2qni03

addons/account_analytic_analysis/account_analytic_analysis.py
addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py

index 76aba53..0d51c95 100644 (file)
@@ -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
index 8787809..0fff5f1 100644 (file)
@@ -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')