From 48bd499f810c99e4f29d1f93ff7a0e0e934f1d27 Mon Sep 17 00:00:00 2001 From: FrankC013 Date: Wed, 9 Oct 2024 11:17:25 +0200 Subject: [PATCH] [IMP] account_invoice_batches: allow inheriting the selectable options of the selection for the batch sending method --- account_invoice_batches/models/__init__.py | 1 - account_invoice_batches/models/account_move.py | 4 +--- account_invoice_batches/models/common.py | 12 ------------ account_invoice_batches/models/res_partner.py | 15 +++++++++++---- .../wizard/account_invoice_batch_process.xml | 1 + 5 files changed, 13 insertions(+), 20 deletions(-) delete mode 100644 account_invoice_batches/models/common.py diff --git a/account_invoice_batches/models/__init__.py b/account_invoice_batches/models/__init__.py index e7c7348cc..3d62836aa 100644 --- a/account_invoice_batches/models/__init__.py +++ b/account_invoice_batches/models/__init__.py @@ -4,7 +4,6 @@ from . import res_company from . import res_config_settings -from . import common from . import res_partner from . import account_move from . import sale diff --git a/account_invoice_batches/models/account_move.py b/account_invoice_batches/models/account_move.py index 7c1632c67..d00010b0e 100644 --- a/account_invoice_batches/models/account_move.py +++ b/account_invoice_batches/models/account_move.py @@ -4,8 +4,6 @@ from odoo import api, fields, models -from .common import BATCH_SENDING_METHODS - class AccountMove(models.Model): _inherit = "account.move" @@ -18,7 +16,7 @@ class AccountMove(models.Model): copy=False, ) invoice_batch_sending_method = fields.Selection( - selection=BATCH_SENDING_METHODS, + selection=lambda self: self.env["res.partner"]._get_batch_sending_methods(), string="Sending method", tracking=True, ) diff --git a/account_invoice_batches/models/common.py b/account_invoice_batches/models/common.py deleted file mode 100644 index d619d5026..000000000 --- a/account_invoice_batches/models/common.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright NuoBiT Solutions, S.L. () -# Eric Antones -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) - -from odoo import _ - -BATCH_SENDING_METHODS = [ - ("pdf", _("PDF")), - ("email", _("e-mail")), - ("signedfacturae", _("Factura-e signed")), - ("unsignedfacturae", _("Factura-e unsigned")), -] diff --git a/account_invoice_batches/models/res_partner.py b/account_invoice_batches/models/res_partner.py index 90a42aba4..9418f5b0e 100644 --- a/account_invoice_batches/models/res_partner.py +++ b/account_invoice_batches/models/res_partner.py @@ -2,16 +2,23 @@ # Eric Antones # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -from odoo import fields, models - -from .common import BATCH_SENDING_METHODS +from odoo import _, api, fields, models class ResPartner(models.Model): _inherit = "res.partner" + @api.model + def _get_batch_sending_methods(self): + return [ + ("pdf", _("PDF")), + ("email", _("e-mail")), + ("signedfacturae", _("Factura-e signed")), + ("unsignedfacturae", _("Factura-e unsigned")), + ] + invoice_batch_sending_method = fields.Selection( - selection=BATCH_SENDING_METHODS, + selection=lambda self: self._get_batch_sending_methods(), string="Invoice Batch Sending method", required=True, default="pdf", diff --git a/account_invoice_batches/wizard/account_invoice_batch_process.xml b/account_invoice_batches/wizard/account_invoice_batch_process.xml index c17504a37..fe9757314 100644 --- a/account_invoice_batches/wizard/account_invoice_batch_process.xml +++ b/account_invoice_batches/wizard/account_invoice_batch_process.xml @@ -17,6 +17,7 @@ name="invoice_batch_sending_email_template_id" attrs="{'invisible': [('invoice_batch_sending_email', '=', False)]}" /> +