<commit_before># -*- coding: utf-8 -*-
# (c) 2017 <NAME> - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, fields, api
from dateutil.relativedelta import relativedelta


class AccountAnalyticAccount(models.Model):
    _inherit = 'account.analytic.account'

    @api.multi
    def _renovate_contract_from_wizard(self, increase, sale=False):
        for contract in self:
            vals = {'date_start': (fields.Date.from_string(contract.date) +
                                   relativedelta(days=1)),
                    'date': (fields.Date.from_string(contract.date) +
                             relativedelta(years=1))}
            contract.copy(vals)._update_new_contract_renovate_information(
                contract, increase, sale)
            contract.set_close()

    def _update_new_contract_renovate_information(self, origin_contract,
                                                  increase, origin_sale):
        self.name = '{} {}'.format(
            origin_contract.name,
            fields.Date.from_string(self.date_start).year)
        if increase:
            for line in self.recurring_invoice_line_ids.filtered(
                    lambda x: x.price_unit):
                line.price_unit = (line.price_unit +
                                   (line.price_unit * increase))
        self.set_open()
        if origin_sale:
            self._duplicate_sale_order_from_contract(origin_sale,<commit_msg>[FIX] sale_error_renovate_contract: Fix unicode error.<commit_after># -*- coding: utf-8 -*-
# (c) 2017 <NAME> - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, fields, api
from dateutil.relativedelta import relativedelta


class AccountAnalyticAccount(models.Model):
    _inherit = 'account.analytic.account'

    @api.multi
    def _renovate_contract_from_wizard(self, increase, sale=False):
        for contract in self:
            vals = {'date_start': (fields.Date.from_string(contract.date) +
                                   relativedelta(days=1)),
                    'date': (fields.Date.from_string(contract.date) +
                             relativedelta(years=1))}
            contract.copy(vals)._update_new_contract_renovate_information(
                contract, increase, sale)
            contract.set_close()

    def _update_new_contract_renovate_information(self, origin_contract,
                                                  increase, origin_sale):
        self.name = u'{} {}'.format(
            origin_contract.name,
            fields.Date.from_string(self.date_start).year)
        if increase:
            for line in self.recurring_invoice_line_ids.filtered(
                    lambda x: x.price_unit):
                line.price_unit = (line.price_unit +
                                   (line.price_unit * increase))
        self.set_open()
        if origin_sale:
            self._duplicate_sale_order_from_contract(origin_sale,
{'fraction_non_alphanumeric': 0.09760956175298804, 'fraction_numerical': 0.006640106241699867, 'mean_word_length': 2.013, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '256845', 'n_tokens_mistral': 884, 'n_tokens_neox': 835, 'n_words': 148}