From 37bd21da20541d1d26b7ea4d30ac9ca57e056841 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Tue, 28 Feb 2017 18:44:06 +0100 Subject: [PATCH] 80 bank statement import enforce sequence (#67) * enforce journal sequence for statement naming policy * [8.0] enforce journal sequence for statement naming policy * short headers + update view --- account_bank_statement_import/README.rst | 1 + account_bank_statement_import/__openerp__.py | 3 ++- .../models/__init__.py | 3 ++- .../models/account_bank_statement.py | 17 +++++++++++++++++ .../models/account_journal.py | 14 ++++++++++++++ .../views/account_journal.xml | 17 +++++++++++++++++ 6 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 account_bank_statement_import/models/account_bank_statement.py create mode 100644 account_bank_statement_import/models/account_journal.py create mode 100644 account_bank_statement_import/views/account_journal.xml diff --git a/account_bank_statement_import/README.rst b/account_bank_statement_import/README.rst index e83688f..0d3d7c4 100644 --- a/account_bank_statement_import/README.rst +++ b/account_bank_statement_import/README.rst @@ -38,6 +38,7 @@ Contributors * Alexis de Lattre * Laurent Mignon * Ronald Portier +* Luc De Meyer Maintainer ---------- diff --git a/account_bank_statement_import/__openerp__.py b/account_bank_statement_import/__openerp__.py index 6961e9a..ba892be 100644 --- a/account_bank_statement_import/__openerp__.py +++ b/account_bank_statement_import/__openerp__.py @@ -2,7 +2,7 @@ { 'name': 'Account Bank Statement Import', 'category': 'Banking addons', - 'version': '8.0.1.0.2', + 'version': '8.0.1.1.0', 'license': 'AGPL-3', 'author': 'OpenERP SA,' 'Odoo Community Association (OCA)', @@ -11,6 +11,7 @@ 'data': [ 'views/account_config_settings.xml', 'views/account_bank_statement_import_view.xml', + 'views/account_journal.xml', ], 'demo': [ 'demo/fiscalyear_period.xml', diff --git a/account_bank_statement_import/models/__init__.py b/account_bank_statement_import/models/__init__.py index 7fbdca1..ea103da 100644 --- a/account_bank_statement_import/models/__init__.py +++ b/account_bank_statement_import/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- - from . import res_partner_bank +from . import account_bank_statement from . import account_bank_statement_import from . import account_config_settings +from . import account_journal diff --git a/account_bank_statement_import/models/account_bank_statement.py b/account_bank_statement_import/models/account_bank_statement.py new file mode 100644 index 0000000..1d8c05a --- /dev/null +++ b/account_bank_statement_import/models/account_bank_statement.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import api, models + + +class AccountBankStatement(models.Model): + _inherit = 'account.bank.statement' + + @api.model + def create(self, vals): + if vals.get('name'): + journal = self.env['account.journal'].browse( + vals.get('journal_id')) + if journal.enforce_sequence: + vals['name'] = '/' + return super(AccountBankStatement, self).create(vals) diff --git a/account_bank_statement_import/models/account_journal.py b/account_bank_statement_import/models/account_journal.py new file mode 100644 index 0000000..b49acdd --- /dev/null +++ b/account_bank_statement_import/models/account_journal.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright 2009-2016 Noviat +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import models, fields + + +class account_journal(models.Model): + _inherit = 'account.journal' + + enforce_sequence = fields.Boolean( + string="Enforce Sequence", + help="If checked, the Journal Sequence will determine " + "the statement naming policy even if the name is already " + "set manually or by the statement import software.") diff --git a/account_bank_statement_import/views/account_journal.xml b/account_bank_statement_import/views/account_journal.xml new file mode 100644 index 0000000..87f9289 --- /dev/null +++ b/account_bank_statement_import/views/account_journal.xml @@ -0,0 +1,17 @@ + + + + + + account.journal.enforce_sequence + account.journal + + + + + + + + + +