<commit_before># -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models, tools


class ProjectTaskHistoryCumulative(models.Model):
    _name = 'project.task.history.cumulative'
    _inherit = 'project.task.history'
    _auto = False

    end_date = fields.Date(string='End Date')
    nbr_tasks = fields.Integer(string='# of Tasks', readonly=True)
    project_id = fields.Many2one('project.project', string='Project')

    def init(self):
        tools.drop_view_if_exists(self._cr, self._table)

        self._cr.execute(""" CREATE VIEW %s AS (
            SELECT
                history.date::varchar||'-'||history.history_id::varchar AS id,
                history.date AS end_date,
                *
            FROM (
                SELECT
                    h.id AS history_id,
                    h.date+generate_series(0, CAST((coalesce(h.end_date, DATE 'tomorrow')::date - h.date) AS integer)-1) AS date,
                    h.task_id, h.type_id, h.user_id, h.kanban_state,
                    count(h.task_id) as nbr_tasks,
                    greatest(h.remaining_hours, 1) AS remaining_hours, greatest(h.planned_hours, 1) AS planned_hours,
                    t.project_id
                FROM
                    project_task_history AS h
                    JOIN project_task AS t ON (h.task_id = t.id)<commit_msg>[FIX] project: history cumulative bad compute inherit<commit_after># -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models, tools


class ProjectTaskHistoryCumulative(models.Model):
    _name = 'project.task.history.cumulative'
    _inherit = 'project.task.history'
    _auto = False

    end_date = fields.Date(string='End Date', compute=None, readonly=True)
    nbr_tasks = fields.Integer(string='# of Tasks', readonly=True)
    project_id = fields.Many2one('project.project', string='Project')

    def init(self):
        tools.drop_view_if_exists(self._cr, self._table)

        self._cr.execute(""" CREATE VIEW %s AS (
            SELECT
                history.date::varchar||'-'||history.history_id::varchar AS id,
                history.date AS end_date,
                *
            FROM (
                SELECT
                    h.id AS history_id,
                    h.date+generate_series(0, CAST((coalesce(h.end_date, DATE 'tomorrow')::date - h.date) AS integer)-1) AS date,
                    h.task_id, h.type_id, h.user_id, h.kanban_state,
                    count(h.task_id) as nbr_tasks,
                    greatest(h.remaining_hours, 1) AS remaining_hours, greatest(h.planned_hours, 1) AS planned_hours,
                    t.project_id
                FROM
                    project_task_history AS h
                    JOIN project_task AS t ON (h.task_id = t.id)
{'fraction_non_alphanumeric': 0.10462287104622871, 'fraction_numerical': 0.004171011470281543, 'mean_word_length': 2.0584484590860788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1549996', 'n_tokens_mistral': 903, 'n_tokens_neox': 843, 'n_words': 201}