~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to user_story/model/custom_project_task.py

  • Committer: Jose Morales
  • Date: 2014-07-28 20:00:11 UTC
  • mfrom: (543.7.551 7.0-addons-vauxoo)
  • Revision ID: jose@vauxoo.com-20140728200011-csytovehrzwp24lr
[FORWARD PORT] 7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    Copyright (c) 2014 Vauxoo - http://www.vauxoo.com/
 
6
#
 
7
#    This program is free software: you can redistribute it and/or modify
 
8
#    it under the terms of the GNU Affero General Public License as
 
9
#    published by the Free Software Foundation, either version 3 of the
 
10
#    License, or (at your option) any later version.
 
11
#
 
12
#    This program is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    GNU Affero General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU Affero General Public License
 
18
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
##############################################################################
 
21
import time
 
22
import datetime
 
23
 
 
24
from openerp.osv import fields, osv
 
25
from openerp import pooler
 
26
from openerp import tools
 
27
from openerp.tools.translate import _
 
28
 
 
29
from openerp.tools.sql import drop_view_if_exists
 
30
 
 
31
class custom_project_task(osv.Model):
 
32
    _name = "custom.project.task"
 
33
    _auto = False
 
34
    
 
35
    _columns = {
 
36
        'analytic_id': fields.many2one('account.analytic.account', 'Project',
 
37
                    readonly=True, select=True),
 
38
        'counter': fields.integer('Num', readonly=True),
 
39
        'userstory': fields.integer('User Story', readonly=True, 
 
40
                    help='User history id of user history assigned on task.'),
 
41
        'task_user_id': fields.many2one('res.users', 'Task user',
 
42
                    readonly=True, select=True, help='User of project task.'),
 
43
        'project_leader_id': fields.many2one('res.users', 'Leader user',
 
44
                    readonly=True, select=True, help='Leader user of project task.'),
 
45
        'task_id': fields.many2one('project.task', 'Task',
 
46
                    readonly=True, select=True, help='Project task title.'),
 
47
        'deadline': fields.date('Deadline', readonly=True, 
 
48
                    help='Project task deadline.'),
 
49
        'date_end': fields.date('Date End', readonly=True, 
 
50
                    help='Project task Date End.'),
 
51
        'period_end': fields.char('Period End', 128, 
 
52
                    help='Period for the end date of summary work.'),
 
53
        'state': fields.char('State', 128, help='Project task state.'),
 
54
    }
 
55
 
 
56
    def init(self, cr):
 
57
        drop_view_if_exists(cr, 'custom_project_task')
 
58
        cr.execute('''
 
59
            create or replace view custom_project_task as (
 
60
                SELECT
 
61
                    1 AS counter,
 
62
                    task.id AS id,
 
63
                    task.date_deadline AS deadline,
 
64
                    task.user_id AS task_user_id,
 
65
                    task.project_leader_id AS project_leader_id,
 
66
                    task.date_end AS date_end,
 
67
                    to_char(task.date_end,'MM/YYYY') AS period_end,
 
68
                    analytic.id AS analytic_id,
 
69
                    us.id AS userstory,
 
70
                    task.id AS task_id,
 
71
                    task_type.name AS state
 
72
                FROM project_task AS task
 
73
                LEFT JOIN project_project AS project ON project.id = task.project_id
 
74
                LEFT JOIN account_analytic_account AS analytic ON analytic.id = project.analytic_account_id
 
75
                LEFT JOIN user_story AS us ON us.id = task.userstory_id
 
76
                LEFT JOIN project_task_type AS task_type ON task_type.id = task.stage_id
 
77
        )''')