(self)
return csv_string.encode("utf-8")
Generate the AEAT csv file export.
Generate the AEAT csv file export.
Generate the AEAT csv file export .
def _generate_csv(self):
        """Generate the AEAT csv file export."""
        rows = []
        for line in self.declaration_line_ids:
            state_code = line.intrastat_state_id.code
            rows.append(
                (
                    # Estado destino/origen
                    line.src_dest_country_id.code,
                    # Provincia destino/origen
                    SPANISH_STATES.get(state_code, state_code),
                    # Condiciones de entrega
                    line.incoterm_id.code,
                    # Naturaleza de la transacción
                    line.transaction_id.code,
                    # Modalidad de transporte
                    line.transport_id.code,
                    # Puerto/Aeropuerto de carga o descarga
                    False,
                    # Código mercancías CN8
                    line.hs_code_id.local_code,
                    # País origen
                    line.product_origin_country_id.code,
                    # Régimen estadístico
                    False,
                    # Masa neta
                    str(line.weight).replace(".", ","),
                    # Unidades suplementarias
                    str(line.suppl_unit_qty).replace(".", ","),
                    # Valor
                    str(line.amount_company_currency).replace(".", ","),
                    # Valor estadístico
                    str(line.amount_company_currency).replace(".", ","),
                )
            )
        csv_string = self._format_csv(rows, ";")
        return csv_string.encode("utf-8")
def _generate_csv ( self ) : rows = [ ] for line in self . declaration_line_ids : state_code = line . intrastat_state_id . code rows . append ( ( # Estado destino/origen line . src_dest_country_id . code , # Provincia destino/origen SPANISH_STATES . get ( state_code , state_code ) , # Condiciones de entrega line . incoterm_id . code , # Naturaleza de la transacción line . transaction_id . code , # Modalidad de transporte line . transport_id . code , # Puerto/Aeropuerto de carga o descarga False , # Código mercancías CN8 line . hs_code_id . local_code , # País origen line . product_origin_country_id . code , # Régimen estadístico False , # Masa neta str ( line . weight ) . replace ( "." , "," ) , # Unidades suplementarias str ( line . suppl_unit_qty ) . replace ( "." , "," ) , # Valor str ( line . amount_company_currency ) . replace ( "." , "," ) , # Valor estadístico str ( line . amount_company_currency ) . replace ( "." , "," ) , ) ) csv_string = self . _format_csv ( rows , ";" ) return csv_string . encode ( "utf-8" )