<commit_before># -*- coding: utf-8 -*-
# Copyright 2013-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

import logging
from datetime import datetime, timedelta

from odoo import models, fields, api, exceptions, _

from ..job import STATES, DONE, PENDING, Job, JOB_REGISTRY
from ..utils import get_odoo_module, is_module_installed
from ..exception import RetryableJobError
from ..fields import JobSerialized

_logger = logging.getLogger(__name__)


def channel_func_name(method):
    return '<%s>.%s' % (method.im_class._name, method.__name__)


class QueueJob(models.Model):
    """ Job status and result """
    _name = 'queue.job'
    _description = 'Queue Job'
    _inherit = ['mail.thread', 'ir.needaction_mixin']
    _log_access = False

    _order = 'date_created DESC, date_done DESC'

    _removal_interval = 30  # days

    uuid = fields.Char(string='UUID',
                       readonly=True,
                       index=True,
                       required=True)
    user_id = fields.Many2one(comodel_name='res.users',
                              string='User ID',
                              required=True)
    company_id = fields.Many2one(comodel_name='res.company',
                                 string='Company', index=True)
    name = fields.Char(string='Description', readonly=True)

    model_name = fields.Char(string='Model', readonly=True)
    method_name = fields.Char(readonly=True)
    record_ids = fields.Serialized(readonly=True)
    args = JobSerialized(readonly=True)<commit_msg>[FIX] im_class seems not accessible<commit_after># -*- coding: utf-8 -*-
# Copyright 2013-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

import logging
from datetime import datetime, timedelta

from odoo import models, fields, api, exceptions, _

from ..job import STATES, DONE, PENDING, Job, JOB_REGISTRY
from ..utils import get_odoo_module, is_module_installed
from ..exception import RetryableJobError
from ..fields import JobSerialized

_logger = logging.getLogger(__name__)

from odoo.models import MetaModel


def channel_func_name(method):
    method_class = False
    for key, value in method.func_globals.iteritems():
        if isinstance(value, MetaModel):
            method_class = key
            break
    if not method_class:
        raise TypeError('@job can only be used on methods of Models')
    return '<%s>.%s' % (method_class, method.__name__)


class QueueJob(models.Model):
    """ Job status and result """
    _name = 'queue.job'
    _description = 'Queue Job'
    _inherit = ['mail.thread', 'ir.needaction_mixin']
    _log_access = False

    _order = 'date_created DESC, date_done DESC'

    _removal_interval = 30  # days

    uuid = fields.Char(string='UUID',
                       readonly=True,
                       index=True,
                       required=True)
    user_id = fields.Many2one(comodel_name='res.users',
                              string='User ID',
                              required=True)
    company_id = fields.Many2one(comodel_name='res.company',
                                 string='Company', index=True)
    name = fields.Char(string='Description', readonly=True)

    model_name = fields.Char(string='Model', readonly=True)
    method_name = fields.Char(readonly=True)
    record_ids = fields.Serialized(readonly=True)
    args = JobSerialized(readonly=True)
{'fraction_non_alphanumeric': 0.10644502770487023, 'fraction_numerical': 0.008748906386701663, 'mean_word_length': 2.7816979051819186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3076790', 'n_tokens_mistral': 1050, 'n_tokens_neox': 992, 'n_words': 243}