Server IP : 127.0.0.2 / Your IP : 3.23.59.191 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/addons/project_issue/models/ |
Upload File : |
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, fields, models class Project(models.Model): _inherit = 'project.project' issue_count = fields.Integer(compute='_compute_issue_count', string="Issues") issue_ids = fields.One2many('project.issue', 'project_id', string="Issues", domain=['|', ('stage_id.fold', '=', False), ('stage_id', '=', False)]) label_issues = fields.Char(string='Use Issues as', help="Customize the issues label, for example to call them cases.", default='Issues') use_issues = fields.Boolean(related="analytic_account_id.use_issues", default=True) issue_needaction_count = fields.Integer(compute="_issue_needaction_count", string="Issues") @api.model def _get_alias_models(self): res = super(Project, self)._get_alias_models() res.append(("project.issue", "Issues")) return res @api.multi def _compute_issue_count(self): for project in self: project.issue_count = self.env['project.issue'].search_count([('project_id', '=', project.id), '|', ('stage_id.fold', '=', False), ('stage_id', '=', False)]) def _issue_needaction_count(self): issue_data = self.env['project.issue'].read_group([('project_id', 'in', self.ids), ('message_needaction', '=', True)], ['project_id'], ['project_id']) result = dict((data['project_id'][0], data['project_id_count']) for data in issue_data) for project in self: project.issue_needaction_count = int(result.get(project.id, 0)) @api.onchange('use_issues', 'use_tasks') def _on_change_use_tasks_or_issues(self): if self.use_tasks and not self.use_issues: self.alias_model = 'project.task' elif not self.use_tasks and self.use_issues: self.alias_model = 'project.issue' @api.multi def write(self, vals): res = super(Project, self).write(vals) if 'active' in vals: # archiving/unarchiving a project does it on its issues, too issues = self.with_context(active_test=False).mapped('issue_ids') issues.write({'active': vals['active']}) return res