<commit_before># -*- coding: utf-8 -*-
##############################################################################
#
#    Account Bank Match
#    Copyright (C) 2016 April
#    1200 Web Development
#    http://1200wd.com/
#
#    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/>.
#
##############################################################################

import logging

from openerp import models, fields, api

_logger = logging.getLogger(__name__)

# TODO: Add constraints and indexes

# Object to store reference patterns of orders and invoices to look for in statement lines
class account_bank_statement_match_references(models.Model):
    _name = "account.bank.statement.match.reference"
    _order = "sequence,name"

    name = fields.Char(string="Reference Pattern", size=32,
                                    help="Regular expression pattern to match reference",
                                    required=True)
    model = fields.Selection(
        [
            ('sale.order', 'Sale Order'),
            ('account.invoice', 'Invoice'),
            ('account.account', 'Account'),
            ('res.partner', 'Partner'),
        ], select=True, required=True
    )
    sequence = fields.Integer('Sequence')
    account_bank_id = fields.Many2one('res.partner.bank', string='Bank Account',
        help='Match only applies to selected bank account. Leave empty to match all bank accounts.',
        domain="[('journal_id', '<>', False)]")
    score = fields.Integer("Score to Share", default=0, required=True, help="Total score to share among all matches of this rule. If 3 matches are found and the score to share is 30 then every match gets a score of 10.")
    score_item = fields.Integer("Score per Match", default=0, required=True, help="Score for each match. Will be added to the shared score.")
    account_account_id = fields.Many2one('account.account', string="Account")
    company_id = fields.Many2one('res.company', string='Company', required=True)


# Object to store found matches to orders/invoices in statement lines
class account_bank_statement_match(models.Model):
    _name = "account.bank.statement.match"<commit_msg>[ADD] Constraint on reference pattern table<commit_after># -*- coding: utf-8 -*-
##############################################################################
#
#    Account Bank Match
#    Copyright (C) 2016 April
#    1200 Web Development
#    http://1200wd.com/
#
#    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/>.
#
##############################################################################

import logging

from openerp import models, fields, api

_logger = logging.getLogger(__name__)

# TODO: Add constraints and indexes

# Object to store reference patterns of orders and invoices to look for in statement lines
class account_bank_statement_match_references(models.Model):
    _name = "account.bank.statement.match.reference"
    _order = "sequence,name"

    name = fields.Char(string="Reference Pattern", size=32,
                                    help="Regular expression pattern to match reference",
                                    required=True)
    model = fields.Selection(
        [
            ('sale.order', 'Sale Order'),
            ('account.invoice', 'Invoice'),
            ('account.account', 'Account'),
            ('res.partner', 'Partner'),
        ], select=True, required=True
    )
    sequence = fields.Integer('Sequence')
    account_bank_id = fields.Many2one('res.partner.bank', string='Bank Account',
        help='Match only applies to selected bank account. Leave empty to match all bank accounts.',
        domain="[('journal_id', '<>', False)]")
    score = fields.Integer("Score to Share", default=0, required=True, help="Total score to share among all matches of this rule. If 3 matches are found and the score to share is 30 then every match gets a score of 10.")
    score_item = fields.Integer("Score per Match", default=0, required=True, help="Score for each match. Will be added to the shared score.")
    account_account_id = fields.Many2one('account.account', string="Account")
    company_id = fields.Many2one('res.company', string='Company', required=True)

    _sql_constraints = [
        ('reference_pattern_name_company_unique', 'unique (name, model, company_id)', 'Use reference pattern only once for each model and for each Company')
    ]


# Object to store found matches to orders/invoices in statement lines
class account_bank_statement_match(models.Model):
    _name = "account.bank.statement.match"
{'fraction_non_alphanumeric': 0.1448799861854602, 'fraction_numerical': 0.008979450872042825, 'mean_word_length': 3.517940717628705, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5104401', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1431, 'n_words': 566}