<commit_before># -*- coding: utf-8 -*-

from openerp import models, fields, api
'''
This module create model of Course
'''

class Course(models.Model):
    '''This class create model of Course'''
    _name = 'openacademy.course' # Model odoo name

    name = fields.Char(string='Title', required=True) # field reserved to identified rec_name
    description = fields.Text(string='Description')
    responsible_id = fields.Many2one('res.users',
                                     ondelete='set null',
                                     string="Responsible",
                                     index=True)
    session_ids = fields.One2many('openacademy.session', 'course_id', string="Sessions")

    @api.multi
    def copy(self, default=None):
        default = dict(default or {})

        copied_count = self.search_count(
            [('name', '=like', u"Copy of {}%".format(self.name))])
        if not copied_count:
            new_name = u"Copy of {}".format(self.name)
        else:
            new_name = u"Copy of {} ({})".format(self.name, copied_count)

        default['name'] = new_name
        return super(Course, self).copy(default)


    _sql_constraints = [
        ('name_description_check',
         'CHECK(name != description)',
         "The title of the course should not be the description"),

        ('name_unique',
         'UNIQUE(name)',
         "The course title must be unique"),
    ]<commit_msg>[REF] openacademy: Add sql constraint identation fixed<commit_after># -*- coding: utf-8 -*-

from openerp import models, fields, api
'''
This module create model of Course
'''

class Course(models.Model):
    '''This class create model of Course'''
    _name = 'openacademy.course' # Model odoo name

    name = fields.Char(string='Title', required=True) # field reserved to identified rec_name
    description = fields.Text(string='Description')
    responsible_id = fields.Many2one('res.users',
                                     ondelete='set null',
                                     string="Responsible",
                                     index=True)
    session_ids = fields.One2many('openacademy.session', 'course_id', string="Sessions")

    @api.multi
    def copy(self, default=None):
        default = dict(default or {})

        copied_count = self.search_count(
            [('name', '=like', u"Copy of {}%".format(self.name))])
        if not copied_count:
            new_name = u"Copy of {}".format(self.name)
        else:
            new_name = u"Copy of {} ({})".format(self.name, copied_count)

        default['name'] = new_name
        return super(Course, self).copy(default)


    _sql_constraints = [
        ('name_description_check',
        'CHECK(name != description)',
        "The title of the course should not be the description"),

        ('name_unique',
        'UNIQUE(name)',
        "The course title must be unique"),
    ]
{'fraction_non_alphanumeric': 0.12908777969018934, 'fraction_numerical': 0.002065404475043029, 'mean_word_length': 2.2836158192090394, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7645644', 'n_tokens_mistral': 820, 'n_tokens_neox': 797, 'n_words': 210}