diff --git a/pos_customer_wallet/models/__init__.py b/pos_customer_wallet/models/__init__.py index bd8374bdb..4a3b8c3b4 100644 --- a/pos_customer_wallet/models/__init__.py +++ b/pos_customer_wallet/models/__init__.py @@ -1,3 +1,4 @@ from . import pos_config +from . import pos_payment_method from . import pos_session from . import res_partner diff --git a/pos_customer_wallet/models/pos_payment_method.py b/pos_customer_wallet/models/pos_payment_method.py new file mode 100644 index 000000000..6031b291d --- /dev/null +++ b/pos_customer_wallet/models/pos_payment_method.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2023 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo import fields, models + + +class PosPaymentMethod(models.Model): + _inherit = "pos.payment.method" + + is_customer_wallet_method = fields.Boolean( + related="journal_id.is_customer_wallet_journal", + store=True, + ) diff --git a/pos_customer_wallet/models/pos_session.py b/pos_customer_wallet/models/pos_session.py index 27e3efaa4..b84c76155 100644 --- a/pos_customer_wallet/models/pos_session.py +++ b/pos_customer_wallet/models/pos_session.py @@ -2,29 +2,17 @@ # # SPDX-License-Identifier: AGPL-3.0-or-later -from odoo import api, models +from odoo import models class PosSession(models.Model): _inherit = "pos.session" - @api.model - def _pos_ui_models_to_load(self): - result = super()._pos_ui_models_to_load() - result.append("account.journal") + def _loader_params_pos_payment_method(self): + result = super()._loader_params_pos_payment_method() + result["search_params"]["fields"].append("is_customer_wallet_method") return result - def _loader_params_account_journal(self): - # TODO: This doesn't call super(), which means that it could be - # incompatible with other modules that also implement this method. Find - # a solution to this problem. - return { - "search_params": { - "domain": [], - "fields": ["is_customer_wallet_journal"], - } - } - def _loader_params_product_product(self): result = super()._loader_params_product_product() result["search_params"]["fields"].append("is_customer_wallet_product")