Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Comunicación VERI*FACTU

Entity: verifactu.mixin

Compute Method: _compute_verifactu_qr_url

Inputs Method Outputs
  • company_id
  • company_id.verifactu_test
"""Returns the URL to be used in the QR code. A sample URL would be (urlencoded):
        https://prewww2.aeat.es/wlpl/TIKECONT/ValidarQR?nif=89890001K&numserie=12345678%26G33&fecha=01-01-2024&importe=241.4
        """
for record in self:
            # FIXME: Not be hard-coded
            agency = self.env.ref("l10n_es_aeat.aeat_tax_agency_spain")
            if record.company_id.verifactu_test:
                qr_base_url = agency.verifactu_qr_base_url_test_address
            else:
                qr_base_url = agency.verifactu_qr_base_url
            qr_values = record._get_verifactu_qr_values()
            # Check all values are ASCII between 32 and 126
            for value in qr_values.values():
                try:
                    str(value).encode("ascii")
                except UnicodeEncodeError as uee:
                    raise UserError(
                        _("QR URL value '{}' is not ASCII").format(value)
                    ) from uee
            # Build QR URL
            qr_url = urlencode(qr_values, encoding="utf-8")
            record.verifactu_qr_url = f"{qr_base_url}?{qr_url}"

Back to entity