diff --git a/README.md b/README.md index e22c542..62257d7 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ Available addons ---------------- addon | version | maintainers | summary --- | --- | --- | --- -[account_ebics](account_ebics/) | 17.0.1.2.2 | | EBICS banking protocol +[account_ebics](account_ebics/) | 17.0.1.3.0 | | EBICS banking protocol [account_ebics_batch](account_ebics_batch/) | 17.0.1.0.1 | | EBICS Files automated import and processing -[account_ebics_batch_payment](account_ebics_batch_payment/) | 17.0.1.0.3 | | Upload Batch Payment via EBICS +[account_ebics_batch_payment](account_ebics_batch_payment/) | 17.0.1.1.0 | | Upload Batch Payment via EBICS [account_ebics_oca_statement_import](account_ebics_oca_statement_import/) | 17.0.1.0.1 | | Use OCA Bank Statement Import with account_ebics [account_ebics_oe](account_ebics_oe/) | 17.0.1.0.0 | | Deploy account_ebics module on Odoo Enterprise -[account_ebics_payment_order](account_ebics_payment_order/) | 17.0.1.1.0 | | Upload Payment Order via EBICS +[account_ebics_payment_order](account_ebics_payment_order/) | 17.0.1.2.0 | | Upload Payment Order via EBICS [//]: # (end addons) diff --git a/account_ebics/__manifest__.py b/account_ebics/__manifest__.py index d2eec99..b67fbd0 100644 --- a/account_ebics/__manifest__.py +++ b/account_ebics/__manifest__.py @@ -1,9 +1,9 @@ -# Copyright 2009-2025 Noviat. +# Copyright 2015 Noviat. # License LGPL-3 or later (https://www.gnu.org/licenses/lgpl). { "name": "EBICS banking protocol", - "version": "17.0.1.2.2", + "version": "17.0.1.3.0", "license": "LGPL-3", "author": "Noviat", "website": "https://www.noviat.com/", diff --git a/account_ebics/models/__init__.py b/account_ebics/models/__init__.py index 0a211c1..4b04a91 100644 --- a/account_ebics/models/__init__.py +++ b/account_ebics/models/__init__.py @@ -1,5 +1,6 @@ from . import fintech_ebics_register from . import account_bank_statement +from . import account_journal from . import ebics_config from . import ebics_file from . import ebics_file_format diff --git a/account_ebics/models/account_journal.py b/account_ebics/models/account_journal.py new file mode 100644 index 0000000..199858c --- /dev/null +++ b/account_ebics/models/account_journal.py @@ -0,0 +1,26 @@ +# Copyright 2026 Noviat. +# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import api, fields, models + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + ebics_config_ids = fields.Many2many( + comodel_name="ebics.config", + relation="account_journal_ebics_config_rel", + readonly=True, + ) + ebics_config_id = fields.Many2one( + comodel_name="ebics.config", + compute="_compute_ebics_config_id", + compute_sudo=True, + ) + + @api.depends("ebics_config_ids") + def _compute_ebics_config_id(self): + for rec in self: + rec.ebics_config_id = rec.ebics_config_ids.filtered( + lambda r: r.state == "confirm" + )[:1] diff --git a/account_ebics/models/ebics_config.py b/account_ebics/models/ebics_config.py index 5582092..8d6ed40 100644 --- a/account_ebics/models/ebics_config.py +++ b/account_ebics/models/ebics_config.py @@ -120,7 +120,8 @@ class EbicsConfig(models.Model): comodel_name="res.company", relation="ebics_config_res_company_rel", string="Companies", - readonly=True, + compute="_compute_company_ids", + store=True, help="Companies sharing this EBICS contract.", ) @@ -154,26 +155,10 @@ class EbicsConfig(models.Model): ) ) - def write(self, vals): - """ - Due to the multi-company nature of the EBICS config we - need to adapt the company_ids in the write method. - """ - if "journal_ids" not in vals: - return super().write(vals) + @api.depends("journal_ids.company_id") + def _compute_company_ids(self): for rec in self: - old_company_ids = rec.journal_ids.mapped("company_id").ids - super(EbicsConfig, rec).write(vals) - new_company_ids = rec.journal_ids.mapped("company_id").ids - updates = [] - for cid in new_company_ids: - if cid in old_company_ids: - old_company_ids.remove(cid) - else: - updates += [(4, cid)] - updates += [(3, x) for x in old_company_ids] - super(EbicsConfig, rec).write({"company_ids": updates}) - return True + rec.company_ids = rec.journal_ids.mapped("company_id") def unlink(self): for ebics_config in self: diff --git a/account_ebics/views/menu.xml b/account_ebics/views/menu.xml index 0ac9cee..db44e5b 100644 --- a/account_ebics/views/menu.xml +++ b/account_ebics/views/menu.xml @@ -82,4 +82,13 @@ sequence="30" /> + + diff --git a/account_ebics/wizards/ebics_xfer.py b/account_ebics/wizards/ebics_xfer.py index 2034ca8..8bb82d6 100644 --- a/account_ebics/wizards/ebics_xfer.py +++ b/account_ebics/wizards/ebics_xfer.py @@ -237,8 +237,8 @@ class EbicsXfer(models.TransientModel): date_from = self.date_from and self.date_from.isoformat() or None date_to = self.date_to and self.date_to.isoformat() or None for df in download_formats: + success = False try: - success = False if df.order_type == "BTD": btf = BusinessTransactionFormat( df.btf_service, @@ -263,7 +263,8 @@ class EbicsXfer(models.TransientModel): } } data = client.download(df.order_type, params=params) - ebics_files += self._handle_download_data(data, df) + if not self.env.context.get("ebics_mark_as_downloaded"): + ebics_files += self._handle_download_data(data, df) success = True except EbicsFunctionalError: err_cnt += 1 @@ -321,8 +322,8 @@ class EbicsXfer(models.TransientModel): order_type=df.order_type, ) tb = "".join(format_exception(*exc_info())) - self.note += "\n%s" % tb - else: + self.note += f"\n{tb}" + finally: # mark received data so that it is not included in further # downloads trans_id = client.last_trans_id diff --git a/account_ebics/wizards/ebics_xfer.xml b/account_ebics/wizards/ebics_xfer.xml index ceb9905..0ec245c 100644 --- a/account_ebics/wizards/ebics_xfer.xml +++ b/account_ebics/wizards/ebics_xfer.xml @@ -1,136 +1,139 @@ - - EBICS File Download - ebics.xfer - 1 - -
- - - + EBICS File Download + ebics.xfer + 1 + + + + + - - - - - - + + + - - - -
-
- -
-
+ + + + - - EBICS File Upload - ebics.xfer - 1 - -
- - - + EBICS File Upload + ebics.xfer + 1 + + + + + - - - - - - - - - - - + + + + + + + - - - - -
-
- -
-
+ + + + - - EBICS File Transfer - ebics.xfer - 2 - -
- - -
-
- -
-
+ + + + - - EBICS File Transfer - Download - ir.actions.act_window - ebics.xfer - form - new - {'ebics_download': 1} - - + + EBICS File Transfer - Download + ir.actions.act_window + ebics.xfer + form + new + {'ebics_download': 1} + + - - EBICS File Transfer - Upload - ir.actions.act_window - ebics.xfer - form - new - {'ebics_upload': 1} - - + + EBICS File Transfer - Upload + ir.actions.act_window + ebics.xfer + form + new + {'ebics_upload': 1} + + + + + Mark EBICS files as Downloaded + ebics.xfer + 1 + +
+ + + + + + + + + + + + +
+
+
+
+
+ + + Mark files as Downloaded + ir.actions.act_window + ebics.xfer + form + new + {'ebics_download': 1, 'ebics_mark_as_downloaded': 1} + +
diff --git a/account_ebics_batch_payment/__manifest__.py b/account_ebics_batch_payment/__manifest__.py index 37759aa..0637d0e 100644 --- a/account_ebics_batch_payment/__manifest__.py +++ b/account_ebics_batch_payment/__manifest__.py @@ -1,9 +1,9 @@ -# Copyright 2009-2024 Noviat. +# Copyright 2020 Noviat. # License LGPL-3 or later (http://www.gnu.org/licenses/lgpl). { "name": "Upload Batch Payment via EBICS", - "version": "17.0.1.0.3", + "version": "17.0.1.1.0", "license": "LGPL-3", "author": "Noviat", "website": "https://www.noviat.com/", diff --git a/account_ebics_batch_payment/models/account_batch_payment.py b/account_ebics_batch_payment/models/account_batch_payment.py index f80ed4e..bdb891d 100644 --- a/account_ebics_batch_payment/models/account_batch_payment.py +++ b/account_ebics_batch_payment/models/account_batch_payment.py @@ -1,32 +1,38 @@ -# Copyright 2009-2023 Noviat. +# Copyright 2020 Noviat. # License LGPL-3 or later (http://www.gnu.org/licenses/lgpl). -from odoo import _, models +from odoo import _, api, fields, models from odoo.exceptions import UserError class AccountBatchPayment(models.Model): _inherit = "account.batch.payment" + hide_ebics_upload = fields.Boolean( + compute="_compute_hide_ebics_upload", default=True + ) + + @api.depends("journal_id.ebics_config_id", "file_generation_enabled", "state") + def _compute_hide_ebics_upload(self): + for rec in self: + rec.hide_ebics_upload = ( + not rec.journal_id.ebics_config_id + or not rec.file_generation_enabled + or rec.state != "sent" + ) + def ebics_upload(self): self.ensure_one() ctx = self.env.context.copy() origin = _("Batch Payment") + ": " + self.name - ebics_config = self.env["ebics.config"].search( - [ - ("journal_ids", "=", self.journal_id.id), - ("state", "=", "confirm"), - ] - ) - if not ebics_config: + if not self.journal_id.ebics_config_id: raise UserError( - _("No active EBICS configuration available " "for the selected bank.") + _("No active EBICS configuration available for the selected bank.") ) - if len(ebics_config) == 1: - ctx["default_ebics_config_id"] = ebics_config.id ctx.update( { + "default_ebics_config_id": self.journal_id.ebics_config_id.id, "default_upload_data": self.export_file, "default_upload_fname": self.export_filename, "origin": origin, @@ -44,7 +50,6 @@ class AccountBatchPayment(models.Model): view = self.env.ref("account_ebics.ebics_xfer_view_form_upload") act = { "name": _("EBICS Upload"), - "view_type": "form", "view_mode": "form", "res_model": "ebics.xfer", "view_id": view.id, diff --git a/account_ebics_batch_payment/views/account_batch_payment_views.xml b/account_ebics_batch_payment/views/account_batch_payment_views.xml index 4fa3326..ed9d7f0 100644 --- a/account_ebics_batch_payment/views/account_batch_payment_views.xml +++ b/account_ebics_batch_payment/views/account_batch_payment_views.xml @@ -7,10 +7,11 @@ diff --git a/account_ebics_payment_order/__manifest__.py b/account_ebics_payment_order/__manifest__.py index 184bb7c..2ae5575 100644 --- a/account_ebics_payment_order/__manifest__.py +++ b/account_ebics_payment_order/__manifest__.py @@ -1,9 +1,9 @@ -# Copyright 2009-2024 Noviat. -# License LGPL-3 or later (http://www.gnu.org/licenses/lgpl). +# Copyright 2015 Noviat. +# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl). { "name": "Upload Payment Order via EBICS", - "version": "17.0.1.1.0", + "version": "17.0.1.2.0", "license": "LGPL-3", "author": "Noviat", "website": "https://www.noviat.com/", diff --git a/account_ebics_payment_order/models/account_payment_mode.py b/account_ebics_payment_order/models/account_payment_mode.py index 92a9fc4..055fbf4 100644 --- a/account_ebics_payment_order/models/account_payment_mode.py +++ b/account_ebics_payment_order/models/account_payment_mode.py @@ -1,5 +1,5 @@ -# Copyright 2009-2024 Noviat. -# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl). +# Copyright 2015 Noviat. +# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl). from odoo import fields, models diff --git a/account_ebics_payment_order/models/account_payment_order.py b/account_ebics_payment_order/models/account_payment_order.py index 14bfa7d..f268734 100644 --- a/account_ebics_payment_order/models/account_payment_order.py +++ b/account_ebics_payment_order/models/account_payment_order.py @@ -1,13 +1,24 @@ -# Copyright 2009-2024 Noviat. -# License LGPL-3 or later (http://www.gnu.org/licenses/lgpl). +# Copyright 2015 Noviat. +# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl). -from odoo import _, models +from odoo import _, api, fields, models from odoo.exceptions import UserError class AccountPaymentOrder(models.Model): _inherit = "account.payment.order" + hide_ebics_upload = fields.Boolean( + compute="_compute_hide_ebics_upload", default=True + ) + + @api.depends("journal_id.ebics_config_id", "state") + def _compute_hide_ebics_upload(self): + for rec in self: + rec.hide_ebics_upload = ( + not rec.journal_id.ebics_config_id or rec.state != "generated" + ) + def ebics_upload(self): self.ensure_one() ctx = self.env.context.copy() @@ -28,8 +39,8 @@ class AccountPaymentOrder(models.Model): if not attach: raise UserError( _( - "This payment order doesn't contains attachements." - "\nPlease generate first the Payment Order file first." + "This payment order doesn't contains attachments." + "\nPlease generate first the Payment Order file." ) ) elif len(attach) > 1: @@ -43,23 +54,16 @@ class AccountPaymentOrder(models.Model): ) else: origin = _("Payment Order") + ": " + self.name - ebics_config = self.env["ebics.config"].search( - [ - ("journal_ids", "=", self.journal_id.id), - ("state", "=", "confirm"), - ] - ) - if not ebics_config: + if not self.journal_id.ebics_config_id: raise UserError( _( "No active EBICS configuration available " "for the selected bank." ) ) - if len(ebics_config) == 1: - ctx["default_ebics_config_id"] = ebics_config.id ctx.update( { + "default_ebics_config_id": self.journal_id.ebics_config_id.id, "default_upload_data": attach.datas, "default_upload_fname": attach.name, "origin": origin, @@ -76,7 +80,6 @@ class AccountPaymentOrder(models.Model): view = self.env.ref("account_ebics.ebics_xfer_view_form_upload") act = { "name": _("EBICS Upload"), - "view_type": "form", "view_mode": "form", "res_model": "ebics.xfer", "view_id": view.id, diff --git a/account_ebics_payment_order/views/account_payment_order_views.xml b/account_ebics_payment_order/views/account_payment_order_views.xml index 46bad82..0a23fad 100644 --- a/account_ebics_payment_order/views/account_payment_order_views.xml +++ b/account_ebics_payment_order/views/account_payment_order_views.xml @@ -7,10 +7,11 @@