From aa66c8fec7555669c3c60b05631db3745d8ec851 Mon Sep 17 00:00:00 2001 From: Zina Rasoamanana Date: Mon, 13 May 2024 15:13:28 +0200 Subject: [PATCH] [IMP] account_banking_fr_lcr: add posibility to disable CRLF within generated CFONB files --- account_banking_fr_lcr/README.rst | 3 +++ account_banking_fr_lcr/__manifest__.py | 5 +++- .../models/account_payment_method.py | 10 +++++++- .../models/account_payment_order.py | 6 +++-- account_banking_fr_lcr/readme/CONFIGURE.rst | 3 +++ .../static/description/index.html | 14 +++++++---- .../views/account_payment_order.xml | 23 +++++++++++++++++++ 7 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 account_banking_fr_lcr/views/account_payment_order.xml diff --git a/account_banking_fr_lcr/README.rst b/account_banking_fr_lcr/README.rst index 66c1fa71b..0159b6820 100644 --- a/account_banking_fr_lcr/README.rst +++ b/account_banking_fr_lcr/README.rst @@ -52,6 +52,9 @@ To configure this module, you need to create a new payment mode linked to the payment method *Lettre de Change Relevé* that is automatically created when you install this module. +Optionnally: within this payment method, +you have the possibility to disable addition of CRLF in generated files. + Usage ===== diff --git a/account_banking_fr_lcr/__manifest__.py b/account_banking_fr_lcr/__manifest__.py index d519d85f6..37b7a0ce4 100644 --- a/account_banking_fr_lcr/__manifest__.py +++ b/account_banking_fr_lcr/__manifest__.py @@ -14,7 +14,10 @@ "category": "French localisation", "depends": ["account_payment_order"], "external_dependencies": {"python": ["unidecode"]}, - "data": ["data/account_payment_method.xml"], + "data": [ + "data/account_payment_method.xml", + "views/account_payment_order.xml", + ], "demo": ["demo/lcr_demo.xml"], "post_init_hook": "lcr_set_unece", "installable": True, diff --git a/account_banking_fr_lcr/models/account_payment_method.py b/account_banking_fr_lcr/models/account_payment_method.py index 4d0dd4f8f..dc93bb435 100644 --- a/account_banking_fr_lcr/models/account_payment_method.py +++ b/account_banking_fr_lcr/models/account_payment_method.py @@ -2,12 +2,20 @@ # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models +from odoo import api, fields, models class AccountPaymentMethod(models.Model): _inherit = "account.payment.method" + fr_lcr_use_crlf = fields.Boolean( + string="Use CRLF in generated CFONB file", + help="""Enable usage of CRLF ('\\r\\n') within generated CFONB files. + Only used for creation of French LCR CFONB fileds. + [By default: True]""", + default=True, + ) + @api.model def _get_payment_method_information(self): res = super()._get_payment_method_information() diff --git a/account_banking_fr_lcr/models/account_payment_order.py b/account_banking_fr_lcr/models/account_payment_order.py index ab276008a..9a6a8e601 100644 --- a/account_banking_fr_lcr/models/account_payment_order.py +++ b/account_banking_fr_lcr/models/account_payment_order.py @@ -152,7 +152,8 @@ def _prepare_first_cfonb_line(self): ] ) assert len(cfonb_line) == 160, "LCR CFONB line must have 160 chars" - cfonb_line += "\r\n" + if self.payment_method_id.fr_lcr_use_crlf: + cfonb_line += "\r\n" return cfonb_line @api.model @@ -206,7 +207,8 @@ def _prepare_cfonb_line(self, line, transactions_count): ] ) assert len(cfonb_line) == 160, "LCR CFONB line must have 160 chars" - cfonb_line += "\r\n" + if self.payment_method_id.fr_lcr_use_crlf: + cfonb_line += "\r\n" return cfonb_line def _prepare_final_cfonb_line(self, total_amount, transactions_count): diff --git a/account_banking_fr_lcr/readme/CONFIGURE.rst b/account_banking_fr_lcr/readme/CONFIGURE.rst index 6ea29093d..dadaa3017 100644 --- a/account_banking_fr_lcr/readme/CONFIGURE.rst +++ b/account_banking_fr_lcr/readme/CONFIGURE.rst @@ -1,3 +1,6 @@ To configure this module, you need to create a new payment mode linked to the payment method *Lettre de Change Relevé* that is automatically created when you install this module. + +Optionnally: within this payment method, +you have the possibility to disable addition of CRLF in generated files. \ No newline at end of file diff --git a/account_banking_fr_lcr/static/description/index.html b/account_banking_fr_lcr/static/description/index.html index 82a93b73f..e60d09ab0 100644 --- a/account_banking_fr_lcr/static/description/index.html +++ b/account_banking_fr_lcr/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :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. 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 customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 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 .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -398,6 +398,8 @@

Configuration

To configure this module, you need to create a new payment mode linked to the payment method Lettre de Change Relevé that is automatically created when you install this module.

+

Optionnally: within this payment method, +you have the possibility to disable addition of CRLF in generated files.

Usage

@@ -429,7 +431,9 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

diff --git a/account_banking_fr_lcr/views/account_payment_order.xml b/account_banking_fr_lcr/views/account_payment_order.xml new file mode 100644 index 000000000..7af3930f1 --- /dev/null +++ b/account_banking_fr_lcr/views/account_payment_order.xml @@ -0,0 +1,23 @@ + + + + + account.payment.method.form (in account_banking_fr_lcr) + account.payment.method + + + + + + + +