diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py
index af8b1615864..c16ed82a580 100644
--- a/addons/analytic/analytic.py
+++ b/addons/analytic/analytic.py
@@ -161,6 +161,7 @@ class account_analytic_account(osv.osv):
"The type 'Analytic account' stands for usual accounts that you only want to use in accounting.\n"\
"If you select Contract or Project, it offers you the possibility to manage the validity and the invoicing options for this account.\n"\
"The special type 'Template of Project' allows you to define a template with default data that you can reuse easily."),
+ 'template_id': fields.many2one('account.analytic.account', 'Template of Contract'),
'description': fields.text('Description'),
'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2),
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'),
@@ -184,6 +185,17 @@ class account_analytic_account(osv.osv):
}, string='Currency', type='many2one', relation='res.currency'),
}
+ def on_change_template(self, cr, uid, ids, template_id, context=None):
+ if not template_id:
+ return {}
+ res = {'value':{}}
+ template = self.browse(cr, uid, template_id, context=context)
+ res['value']['date_start'] = template.date_start
+ res['value']['date'] = template.date
+ res['value']['quantity_max'] = template.quantity_max
+ res['value']['description'] = template.description
+ return res
+
def on_change_partner_id(self, cr, uid, ids,partner_id, name, context={}):
res={}
if partner_id:
diff --git a/addons/analytic/analytic_view.xml b/addons/analytic/analytic_view.xml
index 6d6a38b4b44..d590506a0c6 100644
--- a/addons/analytic/analytic_view.xml
+++ b/addons/analytic/analytic_view.xml
@@ -18,6 +18,7 @@
+
diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py
index 66911f25ff5..53119853c31 100644
--- a/addons/hr_timesheet/hr_timesheet.py
+++ b/addons/hr_timesheet/hr_timesheet.py
@@ -198,6 +198,13 @@ class account_analytic_account(osv.osv):
_columns = {
'use_timesheets': fields.boolean('Timesheets', help="Check this field if this project manages timesheets"),
}
+
+ def on_change_template(self, cr, uid, ids, template_id, context=None):
+ res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, context=context)
+ if template_id and 'value' in res:
+ template = self.browse(cr, uid, template_id, context=context)
+ res['value']['use_timesheets'] = template.use_timesheets
+ return res
account_analytic_account()
diff --git a/addons/project/project.py b/addons/project/project.py
index 9a5ec1f8a35..09b260597f6 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -1226,6 +1226,13 @@ class account_analytic_account(osv.osv):
'use_tasks': fields.boolean('Tasks Mgmt.',help="If check,this contract will be available in the project menu and you will be able to manage tasks or track issues"),
'company_uom_id': fields.related('company_id', 'project_time_mode_id', type='many2one', relation='product.uom'),
}
+
+ def on_change_template(self, cr, uid, ids, template_id, context=None):
+ res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, context=context)
+ if template_id and 'value' in res:
+ template = self.browse(cr, uid, template_id, context=context)
+ res['value']['use_tasks'] = template.use_tasks
+ return res
def _trigger_project_creation(self, cr, uid, vals, context=None):
'''
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py
index ca5bd9224f2..a7c9d2b5bc3 100644
--- a/addons/project_issue/project_issue.py
+++ b/addons/project_issue/project_issue.py
@@ -593,6 +593,13 @@ class account_analytic_account(osv.osv):
'use_issues' : fields.boolean('Issues Tracking', help="Check this field if this project manages issues"),
}
+ def on_change_template(self, cr, uid, ids, template_id, context=None):
+ res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, context=context)
+ if template_id and 'value' in res:
+ template = self.browse(cr, uid, template_id, context=context)
+ res['value']['use_issues'] = template.use_issues
+ return res
+
def _trigger_project_creation(self, cr, uid, vals, context=None):
res = super(account_analytic_account, self)._trigger_project_creation(cr, uid, vals, context=context)
return res or vals.get('use_issues')
diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py
index 7604d43af1b..d5ac3868a5e 100644
--- a/addons/project_long_term/project_long_term.py
+++ b/addons/project_long_term/project_long_term.py
@@ -275,6 +275,13 @@ class account_analytic_account(osv.osv):
_columns = {
'use_phases': fields.boolean('Phases Planing', help="Check this field if project manages phases"),
}
+
+ def on_change_template(self, cr, uid, ids, template_id, context=None):
+ res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, context=context)
+ if template_id and 'value' in res:
+ template = self.browse(cr, uid, template_id, context=context)
+ res['value']['use_phases'] = template.use_phases
+ return res
def _trigger_project_creation(self, cr, uid, vals, context=None):
res= super(account_analytic_account, self)._trigger_project_creation(cr, uid, vals, context=context)