(self)
return res
Support only for one customer.
Support only for one customer.
Support only for one customer .
def build_destinatarios(self):
        """Support only for one customer."""
        gipuzkoa_tax_agency = self.env.ref(
            "l10n_es_ticketbai_api.tbai_tax_agency_gipuzkoa"
        )
        tax_agency = self.company_id.tbai_tax_agency_id
        res = []
        if 100 < len(self.tbai_customer_ids):
            raise exceptions.ValidationError(
                _(
                    "TicketBAI Invoice %s:\n"
                    "Maximum 100 recipients allowed for each Invoice!"
                )
                % self.name
            )
        for customer in self.tbai_customer_ids:
            customer_res = OrderedDict()
            if customer.nif:
                customer_res["NIF"] = customer.nif
            elif customer.idtype and customer.identification_number:
                customer_res["IDOtro"] = OrderedDict()
                if customer.country_code:
                    customer_res["IDOtro"]["CodigoPais"] = customer.country_code
                customer_res["IDOtro"]["IDType"] = customer.idtype
                customer_res["IDOtro"]["ID"] = customer.identification_number
            customer_res["ApellidosNombreRazonSocial"] = customer.name
            if customer.zip:
                customer_res["CodigoPostal"] = customer.zip
            elif tax_agency == gipuzkoa_tax_agency:
                raise exceptions.ValidationError(
                    _(
                        "TicketBAI Invoice %s:\n"
                        "ZIP code for %s is required for the Tax Agency %s!"
                    )
                    % (self.name, customer.name, tax_agency.name)
                )
            if customer.address:
                customer_res["Direccion"] = customer.address
            elif tax_agency == gipuzkoa_tax_agency:
                raise exceptions.ValidationError(
                    _(
                        "TicketBAI Invoice %s:\n"
                        "Address for %s is required for the Tax Agency %s!"
                    )
                    % (self.name, customer.name, tax_agency.name)
                )
            if (
                "NIF" in customer_res or "IDOtro" in customer_res
            ) and "ApellidosNombreRazonSocial" in customer_res:
                res.append(OrderedDict({"IDDestinatario": customer_res}))
        return res
def build_destinatarios ( self ) : gipuzkoa_tax_agency = self . env . ref ( "l10n_es_ticketbai_api.tbai_tax_agency_gipuzkoa" ) tax_agency = self . company_id . tbai_tax_agency_id res = [ ] if 100 < len ( self . tbai_customer_ids ) : raise exceptions . ValidationError ( _ ( "TicketBAI Invoice %s:\n" "Maximum 100 recipients allowed for each Invoice!" ) % self . name ) for customer in self . tbai_customer_ids : customer_res = OrderedDict ( ) if customer . nif : customer_res [ "NIF" ] = customer . nif elif customer . idtype and customer . identification_number : customer_res [ "IDOtro" ] = OrderedDict ( ) if customer . country_code : customer_res [ "IDOtro" ] [ "CodigoPais" ] = customer . country_code customer_res [ "IDOtro" ] [ "IDType" ] = customer . idtype customer_res [ "IDOtro" ] [ "ID" ] = customer . identification_number customer_res [ "ApellidosNombreRazonSocial" ] = customer . name if customer . zip : customer_res [ "CodigoPostal" ] = customer . zip elif tax_agency == gipuzkoa_tax_agency : raise exceptions . ValidationError ( _ ( "TicketBAI Invoice %s:\n" "ZIP code for %s is required for the Tax Agency %s!" ) % ( self . name , customer . name , tax_agency . name ) ) if customer . address : customer_res [ "Direccion" ] = customer . address elif tax_agency == gipuzkoa_tax_agency : raise exceptions . ValidationError ( _ ( "TicketBAI Invoice %s:\n" "Address for %s is required for the Tax Agency %s!" ) % ( self . name , customer . name , tax_agency . name ) ) if ( "NIF" in customer_res or "IDOtro" in customer_res ) and "ApellidosNombreRazonSocial" in customer_res : res . append ( OrderedDict ( { "IDDestinatario" : customer_res } ) ) return res