(self, vals)
return res
For supplier invoices the SII primary key is the supplier
        VAT/ID Otro and the supplier invoice number. Cannot let change these
        values in a SII registered supplier invoice
For supplier invoices the SII primary key is the supplier
        VAT/ID Otro and the supplier invoice number. Cannot let change these
        values in a SII registered supplier invoice
For supplier invoices the SII primary key is the supplier VAT / ID Otro and the supplier invoice number . Cannot let change these values in a SII registered supplier invoice
def write(self, vals):
        """For supplier invoices the SII primary key is the supplier
        VAT/ID Otro and the supplier invoice number. Cannot let change these
        values in a SII registered supplier invoice"""
        for invoice in self.filtered(
            lambda x: x.is_invoice() and x.sii_state != "not_sent"
        ):
            if "invoice_date" in vals:
                raise exceptions.UserError(
                    _(
                        "You cannot change the invoice date of an invoice "
                        "already registered at the SII. You must cancel the "
                        "invoice and create a new one with the correct date"
                    )
                )
            if invoice.move_type in ["in_invoice", "in refund"]:
                if "partner_id" in vals:
                    correct_partners = invoice._sii_get_partner()
                    correct_partners |= correct_partners.child_ids
                    if vals["partner_id"] not in correct_partners.ids:
                        raise exceptions.UserError(
                            _(
                                "You cannot change the supplier of an invoice "
                                "already registered at the SII. You must cancel "
                                "the invoice and create a new one with the "
                                "correct supplier"
                            )
                        )
                elif "ref" in vals:
                    raise exceptions.UserError(
                        _(
                            "You cannot change the supplier invoice number of "
                            "an invoice already registered at the SII. You must "
                            "cancel the invoice and create a new one with the "
                            "correct number"
                        )
                    )
        # Fill sii_refund_type if not set previously. It happens on sales
        # order invoicing process for example.
        if (
            vals.get("move_type")
            and not vals.get("sii_refund_type")
            and not any(self.mapped("sii_refund_type"))
        ):
            vals["sii_refund_type"] = "I"
        res = super().write(vals)
        if vals.get("fiscal_position_id") and not vals.get("sii_registration_key"):
            self.onchange_fiscal_position_id_l10n_es_aeat_sii()
        return res
def write ( self , vals ) : for invoice in self . filtered ( lambda x : x . is_invoice ( ) and x . sii_state != "not_sent" ) : if "invoice_date" in vals : raise exceptions . UserError ( _ ( "You cannot change the invoice date of an invoice " "already registered at the SII. You must cancel the " "invoice and create a new one with the correct date" ) ) if invoice . move_type in [ "in_invoice" , "in refund" ] : if "partner_id" in vals : correct_partners = invoice . _sii_get_partner ( ) correct_partners |= correct_partners . child_ids if vals [ "partner_id" ] not in correct_partners . ids : raise exceptions . UserError ( _ ( "You cannot change the supplier of an invoice " "already registered at the SII. You must cancel " "the invoice and create a new one with the " "correct supplier" ) ) elif "ref" in vals : raise exceptions . UserError ( _ ( "You cannot change the supplier invoice number of " "an invoice already registered at the SII. You must " "cancel the invoice and create a new one with the " "correct number" ) ) # Fill sii_refund_type if not set previously. It happens on sales # order invoicing process for example. if ( vals . get ( "move_type" ) and not vals . get ( "sii_refund_type" ) and not any ( self . mapped ( "sii_refund_type" ) ) ) : vals [ "sii_refund_type" ] = "I" res = super ( ) . write ( vals ) if vals . get ( "fiscal_position_id" ) and not vals . get ( "sii_registration_key" ) : self . onchange_fiscal_position_id_l10n_es_aeat_sii ( ) return res