# Copyright 2026 - Today Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api
from odoo import models

CASHDRO_FIELDS = ["cashdro_host", "cashdro_user", "cashdro_password"]


class PosPaymentMethod(models.Model):
    _inherit = "pos.payment.method"

    @api.model
    def _load_pos_data_fields(self, config_id):
        """Send the CashDro credentials to the PoS front end.

        `pos_payment_method_cashdro` still declares them through
        `_loader_params_pos_payment_method`, the 17.0 loading API, which 18.0
        replaced by this method. That override is dead code, so the front end
        never receives the host and can't build the CashDro url.

        Only the missing fields are added, so this module stays harmless once
        the base one is fixed upstream.
        """
        fields = super()._load_pos_data_fields(config_id)
        fields.extend(field for field in CASHDRO_FIELDS if field not in fields)
        return fields
