def METHOD_NAME(self):
    self.ensure_one()
    # Method helper to filter chained moves
    def destination_moves(_move):
        return _move.mapped("move_dest_ids").filtered(
            lambda r: r.state in ["partially_available", "assigned", "done"]
        )
    if self.product_id.type not in ["product", "consu"]:
        return {}
    moves = self.move_id
    data = []
    if moves:
        for move in moves:
            # Look for chained moves to check how many items we can allow
            # to return. When a product is re-delivered it should be
            # allowed to open an RMA again on it.
            qty = move.product_qty
            qty_returned = 0
            move_dest = destination_moves(move)
            # With the return of the return of the return we could have an
            # infinite loop, so we should avoid it dropping already explored
            # move_dest_ids
            visited_moves = move + move_dest
            while move_dest:
                qty_returned -= sum(move_dest.mapped("product_qty"))
                move_dest = destination_moves(move_dest) - visited_moves
                if move_dest:
                    visited_moves += move_dest
                    qty += sum(move_dest.mapped("product_qty"))
                    move_dest = destination_moves(move_dest) - visited_moves
            # If by chance we get a negative qty we should ignore it
            qty = max(0, sum((qty, qty_returned)))
            data.append(
                {
                    "product": move.product_id,
                    "quantity": qty,
                    "uom": move.product_uom,
                    "picking": move.picking_id,
                    "delivery_note_line_id": self,
                }
            )
    else:
        data.append(
            {
                "product": self.product_id,
                "quantity": self.product_qty,
                "uom": self.product_uom_id,
                "picking": False,
                "delivery_note_line_id": self,
            }
        )
    return data