[MIG] account_statement_import_file: Migration to 18.0

This commit is contained in:
Duy (Đỗ Anh)
2024-11-06 11:26:08 +07:00
parent 81a06ba769
commit a13a4afc7e
10 changed files with 82 additions and 46 deletions

View File

@@ -17,13 +17,13 @@ Import Statement Files
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github
:target: https://github.com/OCA/bank-statement-import/tree/17.0/account_statement_import_file :target: https://github.com/OCA/bank-statement-import/tree/18.0/account_statement_import_file
:alt: OCA/bank-statement-import :alt: OCA/bank-statement-import
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/bank-statement-import-17-0/bank-statement-import-17-0-account_statement_import_file :target: https://translation.odoo-community.org/projects/bank-statement-import-18-0/bank-statement-import-18-0-account_statement_import_file
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=17.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=18.0
:alt: Try me on Runboat :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -81,7 +81,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-import/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-import/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_file%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_file%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@@ -98,10 +98,23 @@ Contributors
------------ ------------
- Odoo S.A. - Odoo S.A.
- Alexis de Lattre <alexis.delattre@akretion.com> - Alexis de Lattre <alexis.delattre@akretion.com>
- Tecnativa - Pedro M. Baeza - Tecnativa - Pedro M. Baeza
- Sygel - Manuel Regidor - Sygel - Manuel Regidor
- Trobz <https://www.trobz.com/>
- Do Anh Duy <duyda@trobz.com>
Other credits
-------------
The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.
Maintainers Maintainers
----------- -----------
@@ -123,6 +136,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-alexis-via| |maintainer-alexis-via|
This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/17.0/account_statement_import_file>`_ project on GitHub. This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/18.0/account_statement_import_file>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -6,7 +6,7 @@
{ {
"name": "Import Statement Files", "name": "Import Statement Files",
"category": "Accounting", "category": "Accounting",
"version": "17.0.1.0.0", "version": "18.0.1.0.0",
"license": "LGPL-3", "license": "LGPL-3",
"depends": ["account_statement_import_base"], "depends": ["account_statement_import_base"],
"author": "Odoo SA, Akretion, Odoo Community Association (OCA)", "author": "Odoo SA, Akretion, Odoo Community Association (OCA)",

View File

@@ -3,7 +3,7 @@
# @author: Alexis de Lattre <alexis.delattre@akretion.com> # @author: Alexis de Lattre <alexis.delattre@akretion.com>
# Licence LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). # Licence LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
from odoo import _, api, models from odoo import api, models
class AccountJournal(models.Model): class AccountJournal(models.Model):
@@ -28,7 +28,7 @@ class AccountJournal(models.Model):
formats_list.sort() formats_list.sort()
import_formats_str = ", ".join(formats_list) import_formats_str = ", ".join(formats_list)
rslt.insert( rslt.insert(
0, ("file_import_oca", _("Import") + "(" + import_formats_str + ")") 0, ("file_import_oca", self.env._(f"Import ({import_formats_str})"))
) )
return rslt return rslt

View File

@@ -2,3 +2,6 @@
- Alexis de Lattre \<<alexis.delattre@akretion.com>\> - Alexis de Lattre \<<alexis.delattre@akretion.com>\>
- Tecnativa - Pedro M. Baeza - Tecnativa - Pedro M. Baeza
- Sygel - Manuel Regidor - Sygel - Manuel Regidor
- Trobz \<<https://www.trobz.com/>\>
- Do Anh Duy \<<duyda@trobz.com>\>

View File

@@ -0,0 +1 @@
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp.

View File

@@ -8,10 +8,11 @@
/* /*
:Author: David Goodger (goodger@python.org) :Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain. :Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils. Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
@@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ; margin-left: 2em ;
margin-right: 2em } margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */ pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee } pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 } pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@ span.option {
span.pre { span.pre {
white-space: pre } white-space: pre }
span.problematic { span.problematic, pre.problematic {
color: red } color: red }
span.section-subtitle { span.section-subtitle {
@@ -368,7 +369,7 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:617132b3a1943c54ccad25dfc759a97108915b2d1f9d78c4c4ed5682358fdc4d !! source digest: sha256:617132b3a1943c54ccad25dfc759a97108915b2d1f9d78c4c4ed5682358fdc4d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-statement-import/tree/17.0/account_statement_import_file"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-statement-import-17-0/bank-statement-import-17-0-account_statement_import_file"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-statement-import/tree/18.0/account_statement_import_file"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-statement-import-18-0/bank-statement-import-18-0-account_statement_import_file"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module is the successor of the module <p>This module is the successor of the module
<strong>account_bank_statement_import</strong> that was part of Odoo Community until <strong>account_bank_statement_import</strong> that was part of Odoo Community until
Odoo v13 and was moved to Odoo Enterprise for Odoo v14 (cf <a class="reference external" href="https://github.com/odoo/odoo/commit/9ba8734f15e1a292ca27b1a026e8366a91b2a8c9">this Odoo v13 and was moved to Odoo Enterprise for Odoo v14 (cf <a class="reference external" href="https://github.com/odoo/odoo/commit/9ba8734f15e1a292ca27b1a026e8366a91b2a8c9">this
@@ -398,7 +399,8 @@ or, for the country-specific formats, in the OCA localization projects.</p>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul> <li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li> <li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li> <li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li> <li><a class="reference internal" href="#other-credits" id="toc-entry-6">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@@ -424,7 +426,7 @@ related statement lines.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_file%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_file%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -443,18 +445,29 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li> <li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
<li>Tecnativa - Pedro M. Baeza</li> <li>Tecnativa - Pedro M. Baeza</li>
<li>Sygel - Manuel Regidor</li> <li>Sygel - Manuel Regidor</li>
<li>Trobz &lt;<a class="reference external" href="https://www.trobz.com/">https://www.trobz.com/</a>&gt;<ul>
<li>Do Anh Duy &lt;<a class="reference external" href="mailto:duyda&#64;trobz.com">duyda&#64;trobz.com</a>&gt;</li>
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
<p>The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2> <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/alexis-via"><img alt="alexis-via" src="https://github.com/alexis-via.png?size=40px" /></a></p> <p><a class="reference external image-reference" href="https://github.com/alexis-via"><img alt="alexis-via" src="https://github.com/alexis-via.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/17.0/account_statement_import_file">OCA/bank-statement-import</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/18.0/account_statement_import_file">OCA/bank-statement-import</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -12,9 +12,7 @@ class TestAccountStatementImportFile(common.TransactionCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super().setUpClass() super().setUpClass()
cls.eur_currency = cls.env["res.currency"].search( cls.eur_currency = cls.env.ref("base.EUR")
[("name", "=", "EUR"), ("active", "=", False)], limit=1
)
cls.eur_currency.write({"active": True}) cls.eur_currency.write({"active": True})
cls.bank_account = cls.env["res.partner.bank"].create( cls.bank_account = cls.env["res.partner.bank"].create(
{"acc_number": "1111111111", "partner_id": cls.env.company.partner_id.id} {"acc_number": "1111111111", "partner_id": cls.env.company.partner_id.id}
@@ -38,7 +36,9 @@ class TestAccountStatementImportFile(common.TransactionCase):
"bank_account_id": cls.bank_account.id, "bank_account_id": cls.bank_account.id,
} }
) )
f_path = file_path("account_statement_import_file/tests/test_file.txt") f_path = file_path(
"account_statement_import_file/tests/samples/test_statement_import.txt"
)
file = base64.b64encode(open(f_path, "rb").read()) file = base64.b64encode(open(f_path, "rb").read())
cls.import_wizard = ( cls.import_wizard = (
cls.env["account.statement.import"] cls.env["account.statement.import"]

View File

@@ -4,7 +4,7 @@
import base64 import base64
import logging import logging
from odoo import _, api, fields, models from odoo import api, fields, models
from odoo.exceptions import UserError from odoo.exceptions import UserError
from odoo.addons.base.models.res_bank import sanitize_account_number from odoo.addons.base.models.res_bank import sanitize_account_number
@@ -34,7 +34,7 @@ class AccountStatementImport(models.TransientModel):
logger.debug("result=%s", result) logger.debug("result=%s", result)
if not result["statement_ids"]: if not result["statement_ids"]:
raise UserError( raise UserError(
_( self.env._(
"You have already imported this file, or this file " "You have already imported this file, or this file "
"only contains already imported transactions." "only contains already imported transactions."
) )
@@ -92,32 +92,36 @@ class AccountStatementImport(models.TransientModel):
self.statement_filename, self.statement_filename,
len(parsing_data), len(parsing_data),
) )
i = 0 for idx, single_statement_data in enumerate(parsing_data, start=1):
for single_statement_data in parsing_data:
i += 1
logger.debug( logger.debug(
"account %d: single_statement_data=%s", i, single_statement_data "account %d: single_statement_data=%s", idx, single_statement_data
) )
self.import_single_statement(single_statement_data, result) self.import_single_statement(single_statement_data, result)
def import_single_statement(self, single_statement_data, result): def import_single_statement(self, single_statement_data, result):
if not isinstance(single_statement_data, tuple): if not isinstance(single_statement_data, tuple):
raise UserError( raise UserError(
_("The parsing of the statement file returned an invalid result.") self.env._(
"The parsing of the statement file returned an invalid result."
)
) )
currency_code, account_number, stmts_vals = single_statement_data currency_code, account_number, stmts_vals = single_statement_data
# Check raw data # Check raw data
if not self._check_parsed_data(stmts_vals): if not self._check_parsed_data(stmts_vals):
return False return False
if not currency_code: if not currency_code:
raise UserError(_("Missing currency code in the bank statement file.")) raise UserError(
self.env._("Missing currency code in the bank statement file.")
)
# account_number can be None (example : QIF) # account_number can be None (example : QIF)
currency = self._match_currency(currency_code) currency = self._match_currency(currency_code)
journal = self._match_journal(account_number, currency) journal = self._match_journal(account_number, currency)
if not journal.default_account_id: if not journal.default_account_id:
raise UserError( raise UserError(
_("The Bank Accounting Account is not set on the journal '%s'.") self.env._(
% journal.display_name "The Bank Accounting Account is not set on the journal '%s'.",
journal.display_name,
)
) )
# Prepare statement data to be used for bank statements creation # Prepare statement data to be used for bank statements creation
stmts_vals = self._complete_stmts_vals(stmts_vals, journal, account_number) stmts_vals = self._complete_stmts_vals(stmts_vals, journal, account_number)
@@ -161,7 +165,7 @@ class AccountStatementImport(models.TransientModel):
a list of triplets. a list of triplets.
""" """
raise UserError( raise UserError(
_( self.env._(
"This bank statement file format is not supported.\n" "This bank statement file format is not supported.\n"
"Did you install the Odoo module to support this format?" "Did you install the Odoo module to support this format?"
) )
@@ -193,11 +197,11 @@ class AccountStatementImport(models.TransientModel):
) )
if not currency: if not currency:
raise UserError( raise UserError(
_( self.env._(
"The bank statement file uses currency '%s' " "The bank statement file uses currency '%s' "
"but there is no such currency in Odoo." "but there is no such currency in Odoo.",
currency_code,
) )
% currency_code
) )
return currency return currency
@@ -208,7 +212,7 @@ class AccountStatementImport(models.TransientModel):
if not account_number: # exemple : QIF if not account_number: # exemple : QIF
if not self.env.context.get("journal_id"): if not self.env.context.get("journal_id"):
raise UserError( raise UserError(
_( self.env._(
"The format of this bank statement file doesn't " "The format of this bank statement file doesn't "
"contain the bank account number, so you must " "contain the bank account number, so you must "
"start the wizard from the right bank journal " "start the wizard from the right bank journal "
@@ -234,7 +238,7 @@ class AccountStatementImport(models.TransientModel):
if journal and ctx_journal_id and journal.id != ctx_journal_id: if journal and ctx_journal_id and journal.id != ctx_journal_id:
ctx_journal = journal_obj.browse(ctx_journal_id) ctx_journal = journal_obj.browse(ctx_journal_id)
raise UserError( raise UserError(
_( self.env._(
"The journal found for the file (%(journal_match)s) is" "The journal found for the file (%(journal_match)s) is"
" different from the selected journal " " different from the selected journal "
"(%(journal_selected)s).", "(%(journal_selected)s).",
@@ -252,7 +256,7 @@ class AccountStatementImport(models.TransientModel):
) )
if bank_accounts: if bank_accounts:
raise UserError( raise UserError(
_( self.env._(
"The bank account with number '%(account_number)s'" "The bank account with number '%(account_number)s'"
" exists in Odoo but it is not set on any bank " " exists in Odoo but it is not set on any bank "
"journal. You should set it on the related bank " "journal. You should set it on the related bank "
@@ -263,7 +267,7 @@ class AccountStatementImport(models.TransientModel):
) )
else: else:
raise UserError( raise UserError(
_( self.env._(
"Could not find any bank account with number " "Could not find any bank account with number "
"'%(account_number)s' linked to partner '" "'%(account_number)s' linked to partner '"
"%(partner_name)s'. You should create the bank " "%(partner_name)s'. You should create the bank "
@@ -281,7 +285,7 @@ class AccountStatementImport(models.TransientModel):
journal_currency = journal.currency_id or company.currency_id journal_currency = journal.currency_id or company.currency_id
if journal_currency != currency: if journal_currency != currency:
raise UserError( raise UserError(
_( self.env._(
"The currency of the bank statement (%(currency_name)s) " "The currency of the bank statement (%(currency_name)s) "
"is not the same as the currency of the journal " "is not the same as the currency of the journal "
"'%(journal_name)s' (%(journal_currency_name)s).", "'%(journal_name)s' (%(journal_currency_name)s).",
@@ -303,7 +307,7 @@ class AccountStatementImport(models.TransientModel):
) )
journal._statement_line_import_update_hook(lvals, speeddict) journal._statement_line_import_update_hook(lvals, speeddict)
if not lvals.get("payment_ref"): if not lvals.get("payment_ref"):
raise UserError(_("Missing payment_ref on a transaction.")) raise UserError(self.env._("Missing payment_ref on a transaction."))
return stmts_vals return stmts_vals
def _create_bank_statements(self, stmts_vals, result): def _create_bank_statements(self, stmts_vals, result):
@@ -354,10 +358,12 @@ class AccountStatementImport(models.TransientModel):
num_ignored = len(existing_st_line_ids) num_ignored = len(existing_st_line_ids)
if num_ignored > 0: if num_ignored > 0:
if num_ignored == 1: if num_ignored == 1:
msg = _("1 transaction had already been imported and was ignored.") msg = self.env._(
"1 transaction had already been imported and was ignored."
)
else: else:
msg = ( msg = self.env._(
_("%d transactions had already been imported and were ignored.") "%d transactions had already been imported and were ignored.",
% num_ignored num_ignored,
) )
result["notifications"].append(msg) result["notifications"].append(msg)

View File

@@ -40,7 +40,7 @@
<record id="account_statement_import_menu" model="ir.ui.menu"> <record id="account_statement_import_menu" model="ir.ui.menu">
<field name="name">Import Statement</field> <field name="name">Import Statement</field>
<field name="parent_id" ref="account.menu_finance_entries_actions" /> <field name="parent_id" ref="account.menu_finance_entries" />
<field name="action" ref="account_statement_import_action" /> <field name="action" ref="account_statement_import_action" />
<field name="sequence" eval="70" /> <field name="sequence" eval="70" />
</record> </record>