(self, cancel=False)
return inv_dict
Build dict with data to send to AEAT WS for invoice types:
        out_invoice and out_refund.

        :param cancel: It indicates if the dictionary is for sending a
          cancellation of the invoice.
        :return: invoices (dict) : Dict XML with data for this invoice.
Build dict with data to send to AEAT WS for invoice types:
        out_invoice and out_refund.
Build dict with data to send to AEAT WS for invoice types : out_invoice and out_refund .
def _get_sii_invoice_dict_out(self, cancel=False):
        """Build dict with data to send to AEAT WS for invoice types:
        out_invoice and out_refund.

        :param cancel: It indicates if the dictionary is for sending a
          cancellation of the invoice.
        :return: invoices (dict) : Dict XML with data for this invoice.
        """
        self.ensure_one()
        invoice_date = self._change_date_format(self.invoice_date)
        partner = self._sii_get_partner()
        company = self.company_id
        ejercicio = fields.Date.to_date(self.date).year
        periodo = "%02d" % fields.Date.to_date(self.date).month
        is_simplified_invoice = self._is_sii_simplified_invoice()
        serial_number = (self.name or "")[0:60]
        if self.sii_thirdparty_invoice:
            serial_number = self.sii_thirdparty_number[0:60]
        inv_dict = {
            "IDFactura": {
                "IDEmisorFactura": {"NIF": company.vat[2:]},
                # On cancelled invoices, number is not filled
                "NumSerieFacturaEmisor": serial_number,
                "FechaExpedicionFacturaEmisor": invoice_date,
            },
            "PeriodoLiquidacion": {"Ejercicio": ejercicio, "Periodo": periodo},
        }
        if not cancel:
            tipo_desglose, not_in_amount_total = self._get_sii_out_taxes()
            amount_total = self.amount_total_signed - not_in_amount_total
            inv_dict["FacturaExpedida"] = {
                "TipoFactura": self._get_sii_invoice_type(),
                "ClaveRegimenEspecialOTrascendencia": (self.sii_registration_key.code),
                "DescripcionOperacion": self.sii_description,
                "TipoDesglose": tipo_desglose,
                "ImporteTotal": amount_total,
            }
            if self.sii_thirdparty_invoice:
                inv_dict["FacturaExpedida"]["EmitidaPorTercerosODestinatario"] = "S"
            if self.sii_macrodata:
                inv_dict["FacturaExpedida"].update(Macrodato="S")
            if self.sii_registration_key_additional1:
                inv_dict["FacturaExpedida"].update(
                    {
                        "ClaveRegimenEspecialOTrascendenciaAdicional1": (
                            self.sii_registration_key_additional1.code
                        )
                    }
                )
            if self.sii_registration_key_additional2:
                inv_dict["FacturaExpedida"].update(
                    {
                        "ClaveRegimenEspecialOTrascendenciaAdicional2": (
                            self.sii_registration_key_additional2.code
                        )
                    }
                )
            if self.sii_registration_key.code in ["12", "13"]:
                inv_dict["FacturaExpedida"]["DatosInmueble"] = {
                    "DetalleInmueble": {
                        "SituacionInmueble": self.sii_property_location,
                        "ReferenciaCatastral": (
                            self.sii_property_cadastrial_code or ""
                        ),
                    }
                }
            exp_dict = inv_dict["FacturaExpedida"]
            if not is_simplified_invoice:
                # Simplified invoices don't have counterpart
                exp_dict["Contraparte"] = {
                    "NombreRazon": partner.name[0:120],
                }
                # Uso condicional de IDOtro/NIF
                exp_dict["Contraparte"].update(self._get_sii_identifier())
            if self.move_type == "out_refund":
                exp_dict["TipoRectificativa"] = self.sii_refund_type
                if self.sii_refund_type == "S":
                    origin = self.refund_invoice_id
                    exp_dict["ImporteRectificacion"] = {
                        "BaseRectificada": abs(origin.amount_untaxed_signed),
                        "CuotaRectificada": abs(
                            origin.amount_total_signed - origin.amount_untaxed_signed
                        ),
                    }
        return inv_dict
def _get_sii_invoice_dict_out ( self , cancel = False ) : self . ensure_one ( ) invoice_date = self . _change_date_format ( self . invoice_date ) partner = self . _sii_get_partner ( ) company = self . company_id ejercicio = fields . Date . to_date ( self . date ) . year periodo = "%02d" % fields . Date . to_date ( self . date ) . month is_simplified_invoice = self . _is_sii_simplified_invoice ( ) serial_number = ( self . name or "" ) [ 0 : 60 ] if self . sii_thirdparty_invoice : serial_number = self . sii_thirdparty_number [ 0 : 60 ] inv_dict = { "IDFactura" : { "IDEmisorFactura" : { "NIF" : company . vat [ 2 : ] } , # On cancelled invoices, number is not filled "NumSerieFacturaEmisor" : serial_number , "FechaExpedicionFacturaEmisor" : invoice_date , } , "PeriodoLiquidacion" : { "Ejercicio" : ejercicio , "Periodo" : periodo } , } if not cancel : tipo_desglose , not_in_amount_total = self . _get_sii_out_taxes ( ) amount_total = self . amount_total_signed - not_in_amount_total inv_dict [ "FacturaExpedida" ] = { "TipoFactura" : self . _get_sii_invoice_type ( ) , "ClaveRegimenEspecialOTrascendencia" : ( self . sii_registration_key . code ) , "DescripcionOperacion" : self . sii_description , "TipoDesglose" : tipo_desglose , "ImporteTotal" : amount_total , } if self . sii_thirdparty_invoice : inv_dict [ "FacturaExpedida" ] [ "EmitidaPorTercerosODestinatario" ] = "S" if self . sii_macrodata : inv_dict [ "FacturaExpedida" ] . update ( Macrodato = "S" ) if self . sii_registration_key_additional1 : inv_dict [ "FacturaExpedida" ] . update ( { "ClaveRegimenEspecialOTrascendenciaAdicional1" : ( self . sii_registration_key_additional1 . code ) } ) if self . sii_registration_key_additional2 : inv_dict [ "FacturaExpedida" ] . update ( { "ClaveRegimenEspecialOTrascendenciaAdicional2" : ( self . sii_registration_key_additional2 . code ) } ) if self . sii_registration_key . code in [ "12" , "13" ] : inv_dict [ "FacturaExpedida" ] [ "DatosInmueble" ] = { "DetalleInmueble" : { "SituacionInmueble" : self . sii_property_location , "ReferenciaCatastral" : ( self . sii_property_cadastrial_code or "" ) , } } exp_dict = inv_dict [ "FacturaExpedida" ] if not is_simplified_invoice : # Simplified invoices don't have counterpart exp_dict [ "Contraparte" ] = { "NombreRazon" : partner . name [ 0 : 120 ] , } # Uso condicional de IDOtro/NIF exp_dict [ "Contraparte" ] . update ( self . _get_sii_identifier ( ) ) if self . move_type == "out_refund" : exp_dict [ "TipoRectificativa" ] = self . sii_refund_type if self . sii_refund_type == "S" : origin = self . refund_invoice_id exp_dict [ "ImporteRectificacion" ] = { "BaseRectificada" : abs ( origin . amount_untaxed_signed ) , "CuotaRectificada" : abs ( origin . amount_total_signed - origin . amount_untaxed_signed ) , } return inv_dict