diff options
| author | Thibault Francois <tfr@openerp.com> | 2011-04-07 13:41:45 +0200 |
|---|---|---|
| committer | Thibault Francois <tfr@openerp.com> | 2011-04-07 13:41:45 +0200 |
| commit | b11a71fd8751bc4fb33faa1f95f7915e230b86ab (patch) | |
| tree | 15aa10c814bd240a7f3a6e2ae6cff0ae67b296de /addons/project_issue_sheet/project_issue_sheet.py | |
| parent | 1a45ff614d9da8c39a120335d2f84ac454c47417 (diff) | |
[MERGE] improvement project-issue
bzr revid: tfr@openerp.com-20110407114145-xvr27pjquxwk9ff0
Diffstat (limited to 'addons/project_issue_sheet/project_issue_sheet.py')
| -rw-r--r-- | addons/project_issue_sheet/project_issue_sheet.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/addons/project_issue_sheet/project_issue_sheet.py b/addons/project_issue_sheet/project_issue_sheet.py index f96ce9a4ac5..e9396f9d030 100644 --- a/addons/project_issue_sheet/project_issue_sheet.py +++ b/addons/project_issue_sheet/project_issue_sheet.py @@ -27,8 +27,36 @@ class project_issue(osv.osv): _description = 'project issue' _columns = { 'timesheet_ids': fields.one2many('hr.analytic.timesheet', 'issue_id', 'Timesheets'), - 'analytic_account_id': fields.related('project_id', 'analytic_account_id', type='many2one', relation='account.analytic.account',string='Analytic Account') + 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'), } + + def on_change_project(self, cr, uid, ids, project_id, context=None): + if not project_id: + return {} + + result = super(project_issue, self).on_change_project(cr, uid, ids, project_id, context=context) + + project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) + if 'value' not in result: + result['value'] = {} + + account = project.analytic_account_id + if account: + result['value']['analytic_account_id'] = account.id + + return result + + def on_change_account_id(self, cr, uid, ids, account_id, context=None): + if not account_id: + return {} + + account = self.pool.get('account.analytic.account').browse(cr, uid, account_id, context=context) + result = {} + + if account and account.state == 'pending': + result = {'warning' : {'title' : _('Analytic Account'), 'message' : _('The Analytic Account is in pending !')}} + + return result project_issue() |
