<commit_before># -*- coding: utf-8 -*-
##############################################################################
#
#    Author: <NAME>
#    Copyright 2010-2015 Camptocamp SA
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, exceptions
from openerp.osv import orm
from openerp.tools.translate import _
from openerp import netsvc


class AccountInvoice(models.Model):
    _inherit = "account.invoice"

    @api.multi
    def action_to_valid(self):
        """Check if analytic account of each lines is not closed"""
        str_error_lines = ""
        errors = False
        for inv in self:
            for line in inv.invoice_line:
                if line.account_analytic_id and \
                        line.account_analytic_id.state in ['close',
                                                           'cancelled']:
                    str_error_lines += "\n- %s" % line.name
                    errors = True
            if errors:
                raise exceptions.Warning(
                    _('UserError'),
                    _("You are trying to validate invoice lines linked to a "
                      "closed or cancelled Analytic Account.\n\n"
                      "Check the following lines:") + str_error_lines)
        self.write({'state': 'to_valid'})
        return True

    state = fields.Selection(
        [
            ('draft', 'Draft'),
            ('to_send', 'To Send'),
            ('to_valid', 'To Validate'),
            ('proforma2', 'Pro-forma'),
            ('open', 'Open'),
            ('paid', 'Paid'),
            ('cancel', 'Canceled')
        ], 'State', select=True, readonly=True)

<commit_msg>[UPD] exceptions.Warning takes only 1 arg<commit_after># -*- coding: utf-8 -*-
##############################################################################
#
#    Author: <NAME>
#    Copyright 2010-2015 Camptocamp SA
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, exceptions
from openerp.osv import orm
from openerp.tools.translate import _
from openerp import netsvc


class AccountInvoice(models.Model):
    _inherit = "account.invoice"

    @api.multi
    def action_to_valid(self):
        """Check if analytic account of each lines is not closed"""
        str_error_lines = ""
        errors = False
        for inv in self:
            for line in inv.invoice_line:
                if line.account_analytic_id and \
                        line.account_analytic_id.state in ['close',
                                                           'cancelled']:
                    str_error_lines += "\n- %s" % line.name
                    errors = True
            if errors:
                raise exceptions.Warning(
                    _("You are trying to validate invoice lines linked to a "
                      "closed or cancelled Analytic Account.\n\n"
                      "Check the following lines:") + str_error_lines)
        self.write({'state': 'to_valid'})
        return True

    state = fields.Selection(
        [
            ('draft', 'Draft'),
            ('to_send', 'To Send'),
            ('to_valid', 'To Validate'),
            ('proforma2', 'Pro-forma'),
            ('open', 'Open'),
            ('paid', 'Paid'),
            ('cancel', 'Canceled')
        ], 'State', select=True, readonly=True)


{'fraction_non_alphanumeric': 0.1523730224812656, 'fraction_numerical': 0.004787676935886761, 'mean_word_length': 2.173712021136063, 'pattern_counts': {'":': 0, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6593681', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1163, 'n_words': 444}