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

from openerp import api, models, fields
from openerp.tools.translate import _
from openerp.exceptions import Warning

import logging
_logger = logging.getLogger(__name__)


class AccountBankStatementLine(models.Model):
    _inherit = "account.bank.statement.line"

    # Ensure transactions can be imported only once (if the import format
    # provides unique transaction ids)
    unique_import_id = fields.Char('Import ID', readonly=True, copy=False)

    _sql_constraints = [
        ('unique_import_id',
         'unique (unique_import_id)',
         'A bank account transactions can be imported only once !')
    ]


class AccountBankStatementImport(models.TransientModel):
    _name = 'account.bank.statement.import'
    _description = 'Import Bank Statement'

    @api.model
    def _get_hide_journal_field(self):
        """ Return False if the journal_id can't be provided by the parsed
        file and must be provided by the wizard.
        See account_bank_statement_import_qif """
        return True

    journal_id = fields.Many2one(
        'account.journal', string='Journal',
        help='Accounting journal related to the bank statement you\'re '
        'importing. It has be be manually chosen for statement formats which '
        'doesn\'t allow automatic journal detection (QIF for example).')
    hide_journal_field = fields.Boolean(
        'Hide the journal field in the view', compute='_get_hide_journal_field')
    data_file = fields.Binary(
        'Bank Statement File', required=True,
        help='Get you bank statements in electronic format from your bank '
        'and select them here.')

    @api.multi
    def import_file(self):
        """ Process the file chosen in the wizard, create bank statement(s) and
        go to reconciliation. """
        self.ensure_one()
        data_file = base64.b64decode(self.data_file)
        statement_ids, notifications = self.with_context(
            active_id=self.id)._import_file(data_file)
        # dispatch to reconciliation interface
        action = self.env.ref(
            'account.action_bank_reconcile_bank_statements')
        return {
            'name': action.name,
            'tag': action.tag,
            'context': {<commit_msg>SDK Merge branch 'upstream/8.0'<commit_after># -*- coding: utf-8 -*-
import base64

from openerp import api, models, fields
from openerp.tools.translate import _
from openerp.exceptions import Warning

import logging
_logger = logging.getLogger(__name__)


class AccountBankStatementLine(models.Model):
    _inherit = "account.bank.statement.line"

    # Ensure transactions can be imported only once (if the import format
    # provides unique transaction ids)
    unique_import_id = fields.Char('Import ID', readonly=True, copy=False)

    _sql_constraints = [
        ('unique_import_id',
         'unique (unique_import_id)',
         'A bank account transactions can be imported only once !')
    ]


class AccountBankStatementImport(models.TransientModel):
    _name = 'account.bank.statement.import'
    _description = 'Import Bank Statement'

    @api.model
    def _get_hide_journal_field(self):
        """ Return False if the journal_id can't be provided by the parsed
        file and must be provided by the wizard.
        See account_bank_statement_import_qif """
        return True

    journal_id = fields.Many2one(
        'account.journal', string='Journal',
        help='Accounting journal related to the bank statement you\'re '
        'importing. It has be be manually chosen for statement formats which '
        'doesn\'t allow automatic journal detection (QIF for example).')
    hide_journal_field = fields.Boolean(
        string='Hide the journal field in the view',
        compute='_get_hide_journal_field')
    data_file = fields.Binary(
        'Bank Statement File', required=True,
        help='Get you bank statements in electronic format from your bank '
        'and select them here.')

    @api.multi
    def import_file(self):
        """ Process the file chosen in the wizard, create bank statement(s) and
        go to reconciliation. """
        self.ensure_one()
        data_file = base64.b64decode(self.data_file)
        statement_ids, notifications = self.with_context(
            active_id=self.id)._import_file(data_file)
        # dispatch to reconciliation interface
        action = self.env.ref(
            'account.action_bank_reconcile_bank_statements')
        return {
            'name': action.name,
            'tag': action.tag,
            'context': {
{'fraction_non_alphanumeric': 0.0861732146733232, 'fraction_numerical': 0.003907097894508357, 'mean_word_length': 2.931740614334471, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5216063', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1220, 'n_words': 385}