<commit_before>##############################################################################
#
#    Copyright (C) 2014-2019 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: <NAME>, <NAME>
#
#    The licence is in the file __manifest__.py
#
##############################################################################

import logging
import os
from datetime import datetime, date

from dateutil.relativedelta import relativedelta
from odoo.addons.child_compassion.models.compassion_hold import HoldType
from odoo.addons.queue_job.job import job, related_action

from odoo import api, fields, models, tools, _
from odoo.exceptions import UserError, ValidationError
from .product_names import GIFT_CATEGORY, SPONSORSHIP_CATEGORY

logger = logging.getLogger(__name__)
THIS_DIR = os.path.dirname(__file__)
testing = tools.config.get("test_enable")


class SponsorshipContract(models.Model):
    _inherit = ["recurring.contract", "compassion.mapped.model"]
    _name = "recurring.contract"

    ##########################################################################
    #                                 FIELDS                                 #
    ##########################################################################
    correspondent_id = fields.Many2one(
        "res.partner",
        string="Correspondent",
        track_visibility="onchange",
        index=True,
        readonly=False,
    )
    partner_codega = fields.Char(
        "Partner ref", related="correspondent_id.ref", readonly=True
    )
    fully_managed = fields.Boolean(compute="_compute_fully_managed", store=True)
    birthday_invoice = fields.Float(
        "Annual birthday gift",
        help="Set the amount to enable automatic invoice creation each year "
             "for a birthday gift. The invoice is set two months before "
             "child's birthday.",
        track_visibility="onchange",
    )
    reading_language = fields.Many2one(
        "res.lang.compassion",
        "Preferred language",
        track_visiblity="onchange",
        readonly=False,
    )
    transfer_partner_id = fields.Many2one(
        "compassion.global.partner", "Transferred to", readonly=False
    )
    global_id = fields.Char(
        help="Connect global ID", readonly=True, copy=False, track_visibility="onchange"
    )
    hold_expiration_date = fields.Datetime(
        help="Used for setting a hold after sponsorship cancellation"
    )
    send_gifts_to = fields.Selection(
        [("partner_id", "Payer"), ("correspondent_id", "Correspondent")],
        default="correspondent_id",
    )
    gift_partner_id = fields.Many2one(
        "res.partner", compute="_compute_gift_partner", readonly=False
    )
    contract_line_ids = fields.One2many(
        default=lambda self: self._get_standard_lines(), readonly=False
    )
    preferred_name = fields.Char(related="child_id.preferred_name")
    suspended_amount = fields.Float(compute="_compute_suspended_amount")

    child_id = fields.Many2one(
        "compassion.child",
        "Sponsored child",
        readonly=True,
        copy=False,
        states={
            "draft": [("readonly", False)],
            "waiting": [("readonly", False)],
            "mandate": [("readonly", False)],
        },
        ondelete="restrict",
        track_visibility="onchange",
        index=True,
    )
    project_id = fields.Many2one(
        "compassion.project", "Project", related="child_id.project_id", readonly=False
    )
    child_name = fields.Char(
        "Sponsored child name", related="child_id.name", readonly=True
    )
    child_code = fields.Char(
        "Sponsored child code", related="child_id.local_id", readonly=True
    )
    is_active = fields.Boolean(
        "Contract Active",
        compute="_compute_active",
        store=True,
        help="It indicates that the first invoice has been paid and the "
             "contract was activated.",
    )
    # Field used for identifying gifts from sponsor
    commitment_number = fields.Integer(
        "Partner Contract Number", required=True, copy=False,
    )
    months_paid = fields.Integer(compute="_compute_months_paid")
    origin_id = fields.Many2one(
        "recurring.contract.origin",
        "Origin",
        ondelete="restrict",
        track_visibility="onchange",
        index=True,
        readonly=False,
    )
    parent_id = fields.Many2one(
        "recurring.contract",
        "Previous sponsorship",
        track_visibility="onchange",
        index=True,
        copy=False,
        readonly=False,
    )
    sub_sponsorship_id = fields.Many2one(
        "recurring.contract", "sub sponsorship", readonly=True, copy=False, index=True
    )
    name = fields.Char(store=True, compute="name_get")
    partner_id = fields.Many2one(
        "res.partner",
        "Partner",
        required=True,
        readonly=False,
        states={"terminated": [("readonly", True)]},
        ondelete="restrict",
        track_visibility="onchange",
    )<commit_msg>FIX copy name of contracts<commit_after>##############################################################################
#
#    Copyright (C) 2014-2019 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: <NAME>, <NAME>
#
#    The licence is in the file __manifest__.py
#
##############################################################################

import logging
import os
from datetime import datetime, date

from dateutil.relativedelta import relativedelta
from odoo.addons.child_compassion.models.compassion_hold import HoldType
from odoo.addons.queue_job.job import job, related_action

from odoo import api, fields, models, tools, _
from odoo.exceptions import UserError, ValidationError
from .product_names import GIFT_CATEGORY, SPONSORSHIP_CATEGORY

logger = logging.getLogger(__name__)
THIS_DIR = os.path.dirname(__file__)
testing = tools.config.get("test_enable")


class SponsorshipContract(models.Model):
    _inherit = ["recurring.contract", "compassion.mapped.model"]
    _name = "recurring.contract"

    ##########################################################################
    #                                 FIELDS                                 #
    ##########################################################################
    correspondent_id = fields.Many2one(
        "res.partner",
        string="Correspondent",
        track_visibility="onchange",
        index=True,
        readonly=False,
    )
    partner_codega = fields.Char(
        "Partner ref", related="correspondent_id.ref", readonly=True
    )
    fully_managed = fields.Boolean(compute="_compute_fully_managed", store=True)
    birthday_invoice = fields.Float(
        "Annual birthday gift",
        help="Set the amount to enable automatic invoice creation each year "
             "for a birthday gift. The invoice is set two months before "
             "child's birthday.",
        track_visibility="onchange",
    )
    reading_language = fields.Many2one(
        "res.lang.compassion",
        "Preferred language",
        track_visiblity="onchange",
        readonly=False,
    )
    transfer_partner_id = fields.Many2one(
        "compassion.global.partner", "Transferred to", readonly=False
    )
    global_id = fields.Char(
        help="Connect global ID", readonly=True, copy=False, track_visibility="onchange"
    )
    hold_expiration_date = fields.Datetime(
        help="Used for setting a hold after sponsorship cancellation"
    )
    send_gifts_to = fields.Selection(
        [("partner_id", "Payer"), ("correspondent_id", "Correspondent")],
        default="correspondent_id",
    )
    gift_partner_id = fields.Many2one(
        "res.partner", compute="_compute_gift_partner", readonly=False
    )
    contract_line_ids = fields.One2many(
        default=lambda self: self._get_standard_lines(), readonly=False
    )
    preferred_name = fields.Char(related="child_id.preferred_name")
    suspended_amount = fields.Float(compute="_compute_suspended_amount")

    child_id = fields.Many2one(
        "compassion.child",
        "Sponsored child",
        readonly=True,
        copy=False,
        states={
            "draft": [("readonly", False)],
            "waiting": [("readonly", False)],
            "mandate": [("readonly", False)],
        },
        ondelete="restrict",
        track_visibility="onchange",
        index=True,
    )
    project_id = fields.Many2one(
        "compassion.project", "Project", related="child_id.project_id", readonly=False
    )
    child_name = fields.Char(
        "Sponsored child name", related="child_id.name", readonly=True
    )
    child_code = fields.Char(
        "Sponsored child code", related="child_id.local_id", readonly=True
    )
    is_active = fields.Boolean(
        "Contract Active",
        compute="_compute_active",
        store=True,
        help="It indicates that the first invoice has been paid and the "
             "contract was activated.",
    )
    # Field used for identifying gifts from sponsor
    commitment_number = fields.Integer(
        "Partner Contract Number", required=True, copy=False,
    )
    months_paid = fields.Integer(compute="_compute_months_paid")
    origin_id = fields.Many2one(
        "recurring.contract.origin",
        "Origin",
        ondelete="restrict",
        track_visibility="onchange",
        index=True,
        readonly=False,
    )
    parent_id = fields.Many2one(
        "recurring.contract",
        "Previous sponsorship",
        track_visibility="onchange",
        index=True,
        copy=False,
        readonly=False,
    )
    sub_sponsorship_id = fields.Many2one(
        "recurring.contract", "sub sponsorship", readonly=True, copy=False, index=True
    )
    name = fields.Char(store=True, compute="name_get", copy=False)
    partner_id = fields.Many2one(
        "res.partner",
        "Partner",
        required=True,
        readonly=False,
        states={"terminated": [("readonly", True)]},
        ondelete="restrict",
        track_visibility="onchange",
    )
{'fraction_non_alphanumeric': 0.16208222419402543, 'fraction_numerical': 0.003746426106674554, 'mean_word_length': 3.05111821086262, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 7, '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': '4141566', 'n_tokens_mistral': 2895, 'n_tokens_neox': 2803, 'n_words': 585}